зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1678292 - handle absence of Local State directory better when checking for chromium data to import, r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D99214
This commit is contained in:
Родитель
c69038dcaf
Коммит
c1e35cf746
|
@ -225,16 +225,16 @@ var ChromeMigrationUtils = {
|
|||
async getLocalState(dataPath = "Chrome") {
|
||||
let localState = null;
|
||||
try {
|
||||
let localStatePath = OS.Path.join(
|
||||
let localStatePath = PathUtils.join(
|
||||
this.getDataPath(dataPath),
|
||||
"Local State"
|
||||
);
|
||||
let localStateJson = await OS.File.read(localStatePath, {
|
||||
encoding: "utf-8",
|
||||
});
|
||||
localState = JSON.parse(localStateJson);
|
||||
localState = JSON.parse(await IOUtils.readUTF8(localStatePath));
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
// Don't report the error if it's just a file not existing.
|
||||
if (ex.name != "NotFoundError") {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
return localState;
|
||||
|
@ -246,7 +246,7 @@ var ChromeMigrationUtils = {
|
|||
* @returns {String} The path of Chrome extension directory.
|
||||
*/
|
||||
getExtensionPath(profileId) {
|
||||
return OS.Path.join(this.getDataPath(), profileId, "Extensions");
|
||||
return PathUtils.join(this.getDataPath(), profileId, "Extensions");
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -281,24 +281,33 @@ var ChromeMigrationUtils = {
|
|||
// Edge is not available on Linux.
|
||||
},
|
||||
};
|
||||
let dirKey, subfolders;
|
||||
subfolders = SUB_DIRECTORIES[AppConstants.platform][chromeProjectName];
|
||||
let subfolders = SUB_DIRECTORIES[AppConstants.platform][chromeProjectName];
|
||||
if (!subfolders) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let rootDir;
|
||||
if (AppConstants.platform == "win") {
|
||||
dirKey = "winLocalAppDataDir";
|
||||
rootDir = "LocalAppData";
|
||||
subfolders = subfolders.concat(["User Data"]);
|
||||
} else if (AppConstants.platform == "macosx") {
|
||||
dirKey = "macUserLibDir";
|
||||
rootDir = "ULibDir";
|
||||
subfolders = ["Application Support"].concat(subfolders);
|
||||
} else {
|
||||
dirKey = "homeDir";
|
||||
rootDir = "Home";
|
||||
subfolders = [".config"].concat(subfolders);
|
||||
}
|
||||
subfolders.unshift(OS.Constants.Path[dirKey]);
|
||||
return OS.Path.join(...subfolders);
|
||||
try {
|
||||
let target = Services.dirsvc.get(rootDir, Ci.nsIFile);
|
||||
for (let subfolder of subfolders) {
|
||||
target.append(subfolder);
|
||||
}
|
||||
return target.path;
|
||||
} catch (ex) {
|
||||
// The path logic here shouldn't error, so log it:
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -165,9 +165,10 @@ ChromeProfileMigrator.prototype.getSourceProfiles = async function Chrome_getSou
|
|||
return [];
|
||||
}
|
||||
|
||||
let localState;
|
||||
let profiles = [];
|
||||
try {
|
||||
let localState = await ChromeMigrationUtils.getLocalState(
|
||||
localState = await ChromeMigrationUtils.getLocalState(
|
||||
this._chromeUserDataPathSuffix
|
||||
);
|
||||
let info_cache = localState.profile.info_cache;
|
||||
|
@ -178,10 +179,13 @@ ChromeProfileMigrator.prototype.getSourceProfiles = async function Chrome_getSou
|
|||
});
|
||||
}
|
||||
} catch (e) {
|
||||
Cu.reportError("Error detecting Chrome profiles: " + e);
|
||||
// Avoid reporting NotFoundErrors from trying to get local state.
|
||||
if (localState || e.name != "NotFoundError") {
|
||||
Cu.reportError("Error detecting Chrome profiles: " + e);
|
||||
}
|
||||
// If we weren't able to detect any profiles above, fallback to the Default profile.
|
||||
let defaultProfilePath = OS.Path.join(chromeUserDataPath, "Default");
|
||||
if (await OS.File.exists(defaultProfilePath)) {
|
||||
let defaultProfilePath = PathUtils.join(chromeUserDataPath, "Default");
|
||||
if (await IOUtils.exists(defaultProfilePath)) {
|
||||
profiles = [
|
||||
{
|
||||
id: "Default",
|
||||
|
|
Загрузка…
Ссылка в новой задаче