mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
Bug 1747463 - Remove FileUtils.getFile from dom/ r=asuth
While here I also migreated the few usages of OSFile over to IOUtils. Differential Revision: https://phabricator.services.mozilla.com/D134900
This commit is contained in:
parent
ce0cb47934
commit
471d308b61
@ -21,7 +21,6 @@ ChromeUtils.defineModuleGetter(
|
||||
"KeyValueService",
|
||||
"resource://gre/modules/kvstore.jsm"
|
||||
);
|
||||
ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"Services",
|
||||
@ -111,11 +110,12 @@ var NotificationDB = {
|
||||
},
|
||||
|
||||
async maybeMigrateData() {
|
||||
// We avoid using OS.File until we know we're going to migrate data
|
||||
// to avoid the performance cost of loading that module.
|
||||
const oldStore = FileUtils.getFile("ProfD", ["notificationstore.json"]);
|
||||
const oldStore = PathUtils.join(
|
||||
Services.dirsvc.get("ProfD", Ci.nsIFile).path,
|
||||
"notificationstore.json"
|
||||
);
|
||||
|
||||
if (!oldStore.exists()) {
|
||||
if (!(await IOUtils.exists(oldStore))) {
|
||||
if (DEBUG) {
|
||||
debug("Old store doesn't exist; not migrating data.");
|
||||
}
|
||||
@ -124,7 +124,7 @@ var NotificationDB = {
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await OS.File.read(oldStore.path, { encoding: "utf-8" });
|
||||
data = await IOUtils.readUTF8(oldStore);
|
||||
} catch (ex) {
|
||||
// If read failed, we assume we have no notifications to migrate.
|
||||
if (DEBUG) {
|
||||
@ -133,7 +133,7 @@ var NotificationDB = {
|
||||
return;
|
||||
} finally {
|
||||
// Finally, delete the old file so we don't try to migrate it again.
|
||||
await OS.File.remove(oldStore.path);
|
||||
await IOUtils.remove(oldStore);
|
||||
}
|
||||
|
||||
if (data.length > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user