summaryrefslogtreecommitdiffstats
path: root/browser/components/backup/resources/AddonsBackupResource.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/backup/resources/AddonsBackupResource.sys.mjs')
-rw-r--r--browser/components/backup/resources/AddonsBackupResource.sys.mjs75
1 files changed, 71 insertions, 4 deletions
diff --git a/browser/components/backup/resources/AddonsBackupResource.sys.mjs b/browser/components/backup/resources/AddonsBackupResource.sys.mjs
index 83b97ed2f2..29b51b8a7f 100644
--- a/browser/components/backup/resources/AddonsBackupResource.sys.mjs
+++ b/browser/components/backup/resources/AddonsBackupResource.sys.mjs
@@ -16,6 +16,73 @@ export class AddonsBackupResource extends BackupResource {
return false;
}
+ async backup(stagingPath, profilePath = PathUtils.profileDir) {
+ // Files and directories to backup.
+ let toCopy = [
+ "extensions.json",
+ "extension-settings.json",
+ "extension-preferences.json",
+ "addonStartup.json.lz4",
+ "browser-extension-data",
+ "extension-store-permissions",
+ ];
+ await BackupResource.copyFiles(profilePath, stagingPath, toCopy);
+
+ // Backup only the XPIs in the extensions directory.
+ let xpiFiles = [];
+ let extensionsXPIDirectoryPath = PathUtils.join(profilePath, "extensions");
+ let xpiDirectoryChildren = await IOUtils.getChildren(
+ extensionsXPIDirectoryPath,
+ {
+ ignoreAbsent: true,
+ }
+ );
+ for (const childFilePath of xpiDirectoryChildren) {
+ if (childFilePath.endsWith(".xpi")) {
+ let childFileName = PathUtils.filename(childFilePath);
+ xpiFiles.push(childFileName);
+ }
+ }
+ // Create the extensions directory in the staging directory.
+ let stagingExtensionsXPIDirectoryPath = PathUtils.join(
+ stagingPath,
+ "extensions"
+ );
+ await IOUtils.makeDirectory(stagingExtensionsXPIDirectoryPath);
+ // Copy all found XPIs to the staging directory.
+ await BackupResource.copyFiles(
+ extensionsXPIDirectoryPath,
+ stagingExtensionsXPIDirectoryPath,
+ xpiFiles
+ );
+
+ // Copy storage sync database.
+ let databases = ["storage-sync-v2.sqlite"];
+ await BackupResource.copySqliteDatabases(
+ profilePath,
+ stagingPath,
+ databases
+ );
+
+ return null;
+ }
+
+ async recover(_manifestEntry, recoveryPath, destProfilePath) {
+ const files = [
+ "extensions.json",
+ "extension-settings.json",
+ "extension-preferences.json",
+ "addonStartup.json.lz4",
+ "browser-extension-data",
+ "extension-store-permissions",
+ "extensions",
+ "storage-sync-v2.sqlite",
+ ];
+ await BackupResource.copyFiles(recoveryPath, destProfilePath, files);
+
+ return null;
+ }
+
async measure(profilePath = PathUtils.profileDir) {
// Report the total size of the extension json files.
const jsonFiles = [
@@ -55,16 +122,16 @@ export class AddonsBackupResource extends BackupResource {
Glean.browserBackup.storageSyncSize.set(storageSyncSize);
// Report the total size of XPI files in the extensions directory.
- let extensionsXpiDirectoryPath = PathUtils.join(profilePath, "extensions");
- let extensionsXpiDirectorySize = await BackupResource.getDirectorySize(
- extensionsXpiDirectoryPath,
+ let extensionsXPIDirectoryPath = PathUtils.join(profilePath, "extensions");
+ let extensionsXPIDirectorySize = await BackupResource.getDirectorySize(
+ extensionsXPIDirectoryPath,
{
shouldExclude: (filePath, fileType) =>
fileType !== "regular" || !filePath.endsWith(".xpi"),
}
);
Glean.browserBackup.extensionsXpiDirectorySize.set(
- extensionsXpiDirectorySize
+ extensionsXPIDirectorySize
);
// Report the total size of the browser extension data.