mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 470810: getDirInternal should cache ProfD. r=robstrong
This commit is contained in:
parent
dd0b5a7308
commit
159c859678
@ -176,6 +176,7 @@ var gOSTarget = null;
|
||||
var gConsole = null;
|
||||
var gInstallManifestRoot = null;
|
||||
var gVersionChecker = null;
|
||||
var gDirService = null;
|
||||
var gLoggingEnabled = null;
|
||||
var gCheckCompatibility = true;
|
||||
var gCheckUpdateSecurity = true;
|
||||
@ -367,9 +368,12 @@ function getDirNoCreate(key, pathArray) {
|
||||
* @return nsIFile object for the location specified.
|
||||
*/
|
||||
function getDirInternal(key, pathArray, shouldCreate) {
|
||||
var fileLocator = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
var dir = fileLocator.get(key, Ci.nsILocalFile);
|
||||
if (!gDirService) {
|
||||
gDirService = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
}
|
||||
|
||||
var dir = gDirService.get(key, Ci.nsILocalFile);
|
||||
for (var i = 0; i < pathArray.length; ++i) {
|
||||
dir.append(pathArray[i]);
|
||||
if (shouldCreate && !dir.exists())
|
||||
@ -2695,6 +2699,7 @@ ExtensionManager.prototype = {
|
||||
gPref = null;
|
||||
gConsole = null;
|
||||
gVersionChecker = null;
|
||||
gDirService = null;
|
||||
gInstallManifestRoot = null;
|
||||
gApp = null;
|
||||
},
|
||||
@ -2707,16 +2712,20 @@ ExtensionManager.prototype = {
|
||||
* be rebuilt, false otherwise.
|
||||
*/
|
||||
_ensureDatasetIntegrity: function EM__ensureDatasetIntegrity() {
|
||||
var extensionsDS = getFile(KEY_PROFILEDIR, [FILE_EXTENSIONS]);
|
||||
var extensionsINI = getFile(KEY_PROFILEDIR, [FILE_EXTENSION_MANIFEST]);
|
||||
var extensionsCache = getFile(KEY_PROFILEDIR, [FILE_EXTENSIONS_STARTUP_CACHE]);
|
||||
var profD = getDirNoCreate(KEY_PROFILEDIR, []);
|
||||
var extensionsDS = profD.clone();
|
||||
extensionsDS.append(FILE_EXTENSIONS);
|
||||
var extensionsINI = profD.clone();
|
||||
extensionsINI.append(FILE_EXTENSION_MANIFEST);
|
||||
var extensionsCache = profD;
|
||||
extensionsCache.append(FILE_EXTENSIONS_STARTUP_CACHE);
|
||||
|
||||
var dsExists = extensionsDS.exists();
|
||||
var iniExists = extensionsINI.exists();
|
||||
var cacheExists = extensionsCache.exists();
|
||||
|
||||
if (dsExists && iniExists && cacheExists)
|
||||
return false;
|
||||
return [false, !iniExists];
|
||||
|
||||
// If any of the files are missing, remove the .ini file
|
||||
if (iniExists)
|
||||
@ -2726,29 +2735,20 @@ ExtensionManager.prototype = {
|
||||
if (!dsExists && cacheExists)
|
||||
extensionsCache.remove(false);
|
||||
|
||||
return true;
|
||||
return [true, !iniExists];
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsIExtensionManager.idl
|
||||
*/
|
||||
start: function EM_start(commandLine) {
|
||||
var isDirty = false;
|
||||
var forceAutoReg = false;
|
||||
|
||||
// Somehow the component list went away, and for that reason the new one
|
||||
// generated by this function is going to result in a different compreg.
|
||||
// We must force a restart.
|
||||
var componentList = getFile(KEY_PROFILEDIR, [FILE_EXTENSION_MANIFEST]);
|
||||
if (!componentList.exists())
|
||||
forceAutoReg = true;
|
||||
var isDirty, forceAutoReg;
|
||||
|
||||
// Check for missing manifests - e.g. missing extensions.ini, missing
|
||||
// extensions.cache, extensions.rdf etc. If any of these files
|
||||
// is missing then we are in some kind of weird or initial state and need
|
||||
// to force a regeneration.
|
||||
if (this._ensureDatasetIntegrity())
|
||||
isDirty = true;
|
||||
[isDirty, forceAutoReg] = this._ensureDatasetIntegrity();
|
||||
|
||||
// Block attempts to flush for the entire startup
|
||||
gAllowFlush = false;
|
||||
@ -3615,9 +3615,8 @@ ExtensionManager.prototype = {
|
||||
gAllowFlush = false;
|
||||
|
||||
// Make the extensions datasource consistent if it isn't already.
|
||||
var isDirty = false;
|
||||
if (this._ensureDatasetIntegrity())
|
||||
isDirty = true;
|
||||
var isDirty;
|
||||
[isDirty,] = this._ensureDatasetIntegrity();
|
||||
|
||||
if (this._checkForFileChanges())
|
||||
isDirty = true;
|
||||
|
Loading…
Reference in New Issue
Block a user