Bug 470810: getDirInternal should cache ProfD. r=robstrong

This commit is contained in:
Dave Townsend 2009-01-06 11:04:41 +00:00
Родитель dd0b5a7308
Коммит 159c859678
1 изменённых файлов: 21 добавлений и 22 удалений

Просмотреть файл

@ -176,6 +176,7 @@ var gOSTarget = null;
var gConsole = null; var gConsole = null;
var gInstallManifestRoot = null; var gInstallManifestRoot = null;
var gVersionChecker = null; var gVersionChecker = null;
var gDirService = null;
var gLoggingEnabled = null; var gLoggingEnabled = null;
var gCheckCompatibility = true; var gCheckCompatibility = true;
var gCheckUpdateSecurity = true; var gCheckUpdateSecurity = true;
@ -367,9 +368,12 @@ function getDirNoCreate(key, pathArray) {
* @return nsIFile object for the location specified. * @return nsIFile object for the location specified.
*/ */
function getDirInternal(key, pathArray, shouldCreate) { function getDirInternal(key, pathArray, shouldCreate) {
var fileLocator = Cc["@mozilla.org/file/directory_service;1"]. if (!gDirService) {
getService(Ci.nsIProperties); gDirService = Cc["@mozilla.org/file/directory_service;1"].
var dir = fileLocator.get(key, Ci.nsILocalFile); getService(Ci.nsIProperties);
}
var dir = gDirService.get(key, Ci.nsILocalFile);
for (var i = 0; i < pathArray.length; ++i) { for (var i = 0; i < pathArray.length; ++i) {
dir.append(pathArray[i]); dir.append(pathArray[i]);
if (shouldCreate && !dir.exists()) if (shouldCreate && !dir.exists())
@ -2695,6 +2699,7 @@ ExtensionManager.prototype = {
gPref = null; gPref = null;
gConsole = null; gConsole = null;
gVersionChecker = null; gVersionChecker = null;
gDirService = null;
gInstallManifestRoot = null; gInstallManifestRoot = null;
gApp = null; gApp = null;
}, },
@ -2707,16 +2712,20 @@ ExtensionManager.prototype = {
* be rebuilt, false otherwise. * be rebuilt, false otherwise.
*/ */
_ensureDatasetIntegrity: function EM__ensureDatasetIntegrity() { _ensureDatasetIntegrity: function EM__ensureDatasetIntegrity() {
var extensionsDS = getFile(KEY_PROFILEDIR, [FILE_EXTENSIONS]); var profD = getDirNoCreate(KEY_PROFILEDIR, []);
var extensionsINI = getFile(KEY_PROFILEDIR, [FILE_EXTENSION_MANIFEST]); var extensionsDS = profD.clone();
var extensionsCache = getFile(KEY_PROFILEDIR, [FILE_EXTENSIONS_STARTUP_CACHE]); 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 dsExists = extensionsDS.exists();
var iniExists = extensionsINI.exists(); var iniExists = extensionsINI.exists();
var cacheExists = extensionsCache.exists(); var cacheExists = extensionsCache.exists();
if (dsExists && iniExists && cacheExists) if (dsExists && iniExists && cacheExists)
return false; return [false, !iniExists];
// If any of the files are missing, remove the .ini file // If any of the files are missing, remove the .ini file
if (iniExists) if (iniExists)
@ -2726,29 +2735,20 @@ ExtensionManager.prototype = {
if (!dsExists && cacheExists) if (!dsExists && cacheExists)
extensionsCache.remove(false); extensionsCache.remove(false);
return true; return [true, !iniExists];
}, },
/** /**
* See nsIExtensionManager.idl * See nsIExtensionManager.idl
*/ */
start: function EM_start(commandLine) { start: function EM_start(commandLine) {
var isDirty = false; var isDirty, forceAutoReg;
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;
// Check for missing manifests - e.g. missing extensions.ini, missing // Check for missing manifests - e.g. missing extensions.ini, missing
// extensions.cache, extensions.rdf etc. If any of these files // 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 // is missing then we are in some kind of weird or initial state and need
// to force a regeneration. // to force a regeneration.
if (this._ensureDatasetIntegrity()) [isDirty, forceAutoReg] = this._ensureDatasetIntegrity();
isDirty = true;
// Block attempts to flush for the entire startup // Block attempts to flush for the entire startup
gAllowFlush = false; gAllowFlush = false;
@ -3615,9 +3615,8 @@ ExtensionManager.prototype = {
gAllowFlush = false; gAllowFlush = false;
// Make the extensions datasource consistent if it isn't already. // Make the extensions datasource consistent if it isn't already.
var isDirty = false; var isDirty;
if (this._ensureDatasetIntegrity()) [isDirty,] = this._ensureDatasetIntegrity();
isDirty = true;
if (this._checkForFileChanges()) if (this._checkForFileChanges())
isDirty = true; isDirty = true;