diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/backup/resources/AddonsBackupResource.sys.mjs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/backup/resources/AddonsBackupResource.sys.mjs')
-rw-r--r-- | browser/components/backup/resources/AddonsBackupResource.sys.mjs | 75 |
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. |