Bug 1897278 - Make the backups profile folder a constant accessible off of the BackupService class. r=backup-reviewers,kpatenio

Differential Revision: https://phabricator.services.mozilla.com/D211437
This commit is contained in:
Mike Conley
2024-06-05 15:24:14 +00:00
parent 3cf4ab3ff3
commit 80cc6a5fa8
3 changed files with 26 additions and 4 deletions

View File

@@ -132,6 +132,16 @@ export class BackupService extends EventTarget {
*/
#postRecoveryResolver;
/**
* The name of the folder within the profile folder where this service reads
* and writes state to.
*
* @type {string}
*/
static get PROFILE_FOLDER_NAME() {
return "backups";
}
/**
* The name of the backup manifest file.
*
@@ -326,7 +336,10 @@ export class BackupService extends EventTarget {
// First, check to see if a `backups` directory already exists in the
// profile.
let backupDirPath = PathUtils.join(profilePath, "backups");
let backupDirPath = PathUtils.join(
profilePath,
BackupService.PROFILE_FOLDER_NAME
);
lazy.logConsole.debug("Creating backups folder");
// ignoreExisting: true is the default, but we're being explicit that it's

View File

@@ -54,7 +54,10 @@ let DebugUI = {
break;
}
case "open-backup-folder": {
let backupsDir = PathUtils.join(PathUtils.profileDir, "backups");
let backupsDir = PathUtils.join(
PathUtils.profileDir,
BackupService.PROFILE_FOLDER_NAME
);
let nsLocalFile = Components.Constructor(
"@mozilla.org/file/local;1",
@@ -71,7 +74,10 @@ let DebugUI = {
break;
}
case "recover-from-staging": {
let backupsDir = PathUtils.join(PathUtils.profileDir, "backups");
let backupsDir = PathUtils.join(
PathUtils.profileDir,
BackupService.PROFILE_FOLDER_NAME
);
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(
Ci.nsIFilePicker
);

View File

@@ -111,7 +111,10 @@ async function testCreateBackupHelper(sandbox, taskFn) {
// We expect the staging folder to exist then be renamed under the fakeProfilePath.
// We should also find a folder for each fake BackupResource.
let backupsFolderPath = PathUtils.join(fakeProfilePath, "backups");
let backupsFolderPath = PathUtils.join(
fakeProfilePath,
BackupService.PROFILE_FOLDER_NAME
);
let stagingPath = PathUtils.join(backupsFolderPath, "staging");
// For now, we expect a single backup only to be saved. There should also be