Bug 1368219 - Remove the unused OSFile.getAvailableFreeSpace. r=Yoric
The test is failing frequently on Linux 32 debug, and the method is unused.
MozReview-Commit-ID: 5ngM1pfDV7g
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -999,31 +999,16 @@ File.move = function move(sourcePath, de
if (!SharedAll.Constants.Win) {
File.unixSymLink = function unixSymLink(sourcePath, destPath) {
return Scheduler.post("unixSymLink", [Type.path.toMsg(sourcePath),
Type.path.toMsg(destPath)], [sourcePath, destPath]);
};
}
/**
- * Gets the number of bytes available on disk to the current user.
- *
- * @param {string} Platform-specific path to a directory on the disk to
- * query for free available bytes.
- *
- * @return {number} The number of bytes available for the current user.
- * @throws {OS.File.Error} In case of any error.
- */
-File.getAvailableFreeSpace = function getAvailableFreeSpace(sourcePath) {
- return Scheduler.post("getAvailableFreeSpace",
- [Type.path.toMsg(sourcePath)], sourcePath
- ).then(Type.uint64_t.fromMsg);
-};
-
-/**
* Remove an empty directory.
*
* @param {string} path The name of the directory to remove.
* @param {*=} options Additional options.
* - {bool} ignoreAbsent If |true|, do not fail if the
* directory does not exist yet.
*/
File.removeEmptyDir = function removeEmptyDir(path, options) {
--- a/toolkit/components/osfile/modules/osfile_async_worker.js
+++ b/toolkit/components/osfile/modules/osfile_async_worker.js
@@ -203,20 +203,16 @@ if (this.Components) {
copy: function copy(sourcePath, destPath, options) {
return File.copy(Type.path.fromMsg(sourcePath),
Type.path.fromMsg(destPath), options);
},
move: function move(sourcePath, destPath, options) {
return File.move(Type.path.fromMsg(sourcePath),
Type.path.fromMsg(destPath), options);
},
- getAvailableFreeSpace: function getAvailableFreeSpace(sourcePath) {
- return Type.uint64_t.toMsg(
- File.getAvailableFreeSpace(Type.path.fromMsg(sourcePath)));
- },
makeDir: function makeDir(path, options) {
return File.makeDir(Type.path.fromMsg(path), options);
},
removeEmptyDir: function removeEmptyDir(path, options) {
return File.removeEmptyDir(Type.path.fromMsg(path), options);
},
remove: function remove(path, options) {
return File.remove(Type.path.fromMsg(path), options);
--- a/toolkit/components/osfile/modules/osfile_unix_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_unix_front.jsm
@@ -383,37 +383,16 @@
ctypes.errno == Const.ENOENT) {
return;
}
throw new File.Error("removeEmptyDir", ctypes.errno, path);
}
};
/**
- * Gets the number of bytes available on disk to the current user.
- *
- * @param {string} sourcePath Platform-specific path to a directory on
- * the disk to query for free available bytes.
- *
- * @return {number} The number of bytes available for the current user.
- * @throws {OS.File.Error} In case of any error.
- */
- File.getAvailableFreeSpace = function Unix_getAvailableFreeSpace(sourcePath) {
- let fileSystemInfo = new Type.statvfs.implementation();
- let fileSystemInfoPtr = fileSystemInfo.address();
-
- throw_on_negative("statvfs", (UnixFile.statvfs || UnixFile.statfs)(sourcePath, fileSystemInfoPtr));
-
- let bytes = new Type.uint64_t.implementation(
- fileSystemInfo.f_frsize * fileSystemInfo.f_bavail);
-
- return bytes.value;
- };
-
- /**
* Default mode for opening directories.
*/
const DEFAULT_UNIX_MODE_DIR = Const.S_IRWXU;
/**
* Create a directory.
*
* @param {string} path The name of the directory.
--- a/toolkit/components/osfile/modules/osfile_win_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_win_front.jsm
@@ -652,36 +652,16 @@
}
// sd will be set only if the function succeeds.
if (!sd.isNull()) {
WinFile.LocalFree(Type.HLOCAL.cast(sd));
}
};
/**
- * Gets the number of bytes available on disk to the current user.
- *
- * @param {string} sourcePath Platform-specific path to a directory on
- * the disk to query for free available bytes.
- *
- * @return {number} The number of bytes available for the current user.
- * @throws {OS.File.Error} In case of any error.
- */
- File.getAvailableFreeSpace = function Win_getAvailableFreeSpace(sourcePath) {
- let freeBytesAvailableToUser = new Type.uint64_t.implementation(0);
- let freeBytesAvailableToUserPtr = freeBytesAvailableToUser.address();
-
- throw_on_zero("getAvailableFreeSpace",
- WinFile.GetDiskFreeSpaceEx(sourcePath, freeBytesAvailableToUserPtr, null, null)
- );
-
- return freeBytesAvailableToUser.value;
- };
-
- /**
* A global value used to receive data during time conversions.
*/
let gSystemTime = new Type.SystemTime.implementation();
let gSystemTimePtr = gSystemTime.address();
/**
* Utility function: convert a FILETIME to a JavaScript Date.
*/
deleted file mode 100644
--- a/toolkit/components/osfile/tests/xpcshell/test_available_free_space.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-Components.utils.import("resource://gre/modules/osfile.jsm");
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-do_register_cleanup(function() {
- Services.prefs.setBoolPref("toolkit.osfile.log", false);
-});
-
-function run_test() {
- Services.prefs.setBoolPref("toolkit.osfile.log", true);
-
- run_next_test();
-}
-
-/**
- * Test OS.File.getAvailableFreeSpace
- */
-add_task(async function() {
- // Set up profile. We will use profile path to query for available free
- // space.
- do_get_profile();
-
- let dir = OS.Constants.Path.profileDir;
-
- // Sanity checking for the test
- do_check_true((await OS.File.exists(dir)));
-
- // Query for available bytes for user
- let availableBytes = await OS.File.getAvailableFreeSpace(dir);
-
- do_check_true(!!availableBytes);
- do_check_true(availableBytes > 0);
-});
--- a/toolkit/components/osfile/tests/xpcshell/xpcshell.ini
+++ b/toolkit/components/osfile/tests/xpcshell/xpcshell.ini
@@ -1,15 +1,14 @@
[DEFAULT]
head = head.js
support-files =
test_loader/module_test_loader.js
-[test_available_free_space.js]
[test_compression.js]
[test_constants.js]
[test_creationDate.js]
[test_duration.js]
[test_exception.js]
[test_file_URL_conversion.js]
[test_loader.js]
[test_logging.js]