diff --git a/toolkit/components/satchel/FormHistory.jsm b/toolkit/components/satchel/FormHistory.jsm index e7fffd76a6a6..d11fbab1c08d 100644 --- a/toolkit/components/satchel/FormHistory.jsm +++ b/toolkit/components/satchel/FormHistory.jsm @@ -94,7 +94,6 @@ const { AppConstants } = ChromeUtils.import( const lazy = {}; -ChromeUtils.defineModuleGetter(lazy, "OS", "resource://gre/modules/osfile.jsm"); ChromeUtils.defineModuleGetter( lazy, "Sqlite", @@ -785,7 +784,7 @@ var DB = { /** String representing where the FormHistory database is on the filesystem */ get path() { - return lazy.OS.Path.join(lazy.OS.Constants.Path.profileDir, DB_FILENAME); + return PathUtils.join(PathUtils.profileDir, DB_FILENAME); }, /** @@ -980,12 +979,13 @@ var DB = { await conn.close(); } let backupFile = this.path + ".corrupt"; - let { file, path: uniquePath } = await lazy.OS.File.openUnique(backupFile, { - humanReadable: true, - }); - await file.close(); - await lazy.OS.File.copy(this.path, uniquePath); - await lazy.OS.File.remove(this.path); + let uniquePath = await IOUtils.createUniqueFile( + PathUtils.parent(backupFile), + PathUtils.filename(backupFile), + 0o600 + ); + await IOUtils.copy(this.path, uniquePath); + await IOUtils.remove(this.path); log("Completed DB cleanup."); }, diff --git a/toolkit/components/satchel/test/unit/head_satchel.js b/toolkit/components/satchel/test/unit/head_satchel.js index 11b6ab2295a5..5f42509b0250 100644 --- a/toolkit/components/satchel/test/unit/head_satchel.js +++ b/toolkit/components/satchel/test/unit/head_satchel.js @@ -18,7 +18,6 @@ var { XPCOMUtils } = ChromeUtils.importESModule( XPCOMUtils.defineLazyModuleGetters(this, { FormHistory: "resource://gre/modules/FormHistory.jsm", FormHistoryTestUtils: "resource://testing-common/FormHistoryTestUtils.jsm", - OS: "resource://gre/modules/osfile.jsm", Sqlite: "resource://gre/modules/Sqlite.jsm", }); @@ -205,21 +204,21 @@ async function copyToProfile( aDestFilename, { overwriteExisting = false } = {} ) { - let curDir = await OS.File.getCurrentDirectory(); - let srcPath = OS.Path.join(curDir, aFilename); - Assert.ok(await OS.File.exists(srcPath), "Database file found"); + let curDir = Services.dirsvc.get("CurWorkD", Ci.nsIFile).path; + let srcPath = PathUtils.join(curDir, aFilename); + Assert.ok(await IOUtils.exists(srcPath), "Database file found"); // Ensure that our file doesn't exist already. - let destPath = OS.Path.join(OS.Constants.Path.profileDir, aDestFilename); - let exists = await OS.File.exists(destPath); + let destPath = PathUtils.join(PathUtils.profileDir, aDestFilename); + let exists = await IOUtils.exists(destPath); if (exists) { if (overwriteExisting) { - await OS.file.remove(destPath); + await IOUtils.remove(destPath); } else { throw new Error("The file should not exist"); } } - await OS.File.copy(srcPath, destPath); + await IOUtils.copy(srcPath, destPath); info(`Copied ${aFilename} to ${destPath}`); return destPath; }