From 0dac3de193ef9c1cefd0cb6a0d21615d6e1416ee Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Mon, 29 Dec 2008 09:31:25 +0000 Subject: [PATCH] Bug 470379: Remove code to upgrade from 1.0 profiles. r=robstrong --- .../extensions/src/nsExtensionManager.js.in | 189 ------------------ 1 file changed, 189 deletions(-) diff --git a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in index 3b0d19a6199..3ac329e85eb 100644 --- a/toolkit/mozapps/extensions/src/nsExtensionManager.js.in +++ b/toolkit/mozapps/extensions/src/nsExtensionManager.js.in @@ -3614,11 +3614,6 @@ ExtensionManager.prototype = { // Block attempts to flush for the entire startup gAllowFlush = false; - // Version mismatch, we have to load the extensions datasource and do - // version checking. Time hit here doesn't matter since this doesn't happen - // all that often. - this._upgradeFromV10(); - // Make the extensions datasource consistent if it isn't already. var isDirty = false; if (this._ensureDatasetIntegrity()) @@ -3792,190 +3787,6 @@ ExtensionManager.prototype = { } }, - /* - * Catch all for facilitating a version 1.0 profile upgrade. - * 1) removes the abandoned default theme directory from the profile. - * 2) prepares themes installed with version 1.0 for installation. - * 3) initiates an install to populate the new extensions datasource. - * 4) migrates the disabled attribute from the old datasource. - * 5) migrates the app compatibility info from the old datasource. - */ - _upgradeFromV10: function EM__upgradeFromV10() { - var extensionsDS = getFile(KEY_PROFILEDIR, [FILE_EXTENSIONS]); - var dsExists = extensionsDS.exists(); - // Toolkiit 1.7 profiles (Firefox 1.0, Thunderbird 1.0, etc.) have a default - // theme directory in the profile's extensions directory that will be - // disabled due to having a maxVersion that is incompatible with the - // toolkit 1.8 release of the app. - var profileDefaultTheme = getDirNoCreate(KEY_PROFILEDS, [DIR_EXTENSIONS, - stripPrefix(RDFURI_DEFAULT_THEME, PREFIX_ITEM_URI)]); - if (profileDefaultTheme && profileDefaultTheme.exists()) { - removeDirRecursive(profileDefaultTheme); - // Sunbird 0.3a1 didn't move the default theme into the app's extensions - // directory and we can't install it while uninstalling the one in the - // profile directory. If we have a toolkit 1.8 extensions datasource and - // a profile default theme deleting the toolkit 1.8 extensions datasource - // will fix this problem when the datasource is re-created. - if (dsExists) - extensionsDS.remove(false); - } - - // return early if the toolkit 1.7 extensions datasource file doesn't exist. - var oldExtensionsFile = getFile(KEY_PROFILEDIR, [DIR_EXTENSIONS, "Extensions.rdf"]); - if (!oldExtensionsFile.exists()) - return; - - // Sunbird 0.2 used a different GUID for the default theme - profileDefaultTheme = getDirNoCreate(KEY_PROFILEDS, [DIR_EXTENSIONS, - "{8af2d0a7-e394-4de2-ae55-2dae532a7a9b}"]); - if (profileDefaultTheme && profileDefaultTheme.exists()) - removeDirRecursive(profileDefaultTheme); - - // Firefox 0.9 profiles may have DOMi 1.0 with just an install.rdf - var profileDOMi = getDirNoCreate(KEY_PROFILEDS, [DIR_EXTENSIONS, - "{641d8d09-7dda-4850-8228-ac0ab65e2ac9}"]); - if (profileDOMi && profileDOMi.exists()) - removeDirRecursive(profileDOMi); - - // return early to avoid migrating data twice if we already have a - // toolkit 1.8 extension datasource. - if (dsExists) - return; - - // Prepare themes for installation - // Only enumerate directories in the app-profile and app-global locations. - var locations = [KEY_APP_PROFILE, KEY_APP_GLOBAL]; - for (var i = 0; i < locations.length; ++i) { - var location = InstallLocations.get(locations[i]); - if (!location.canAccess) - continue; - - var entries = location.itemLocations; - var entry; - while ((entry = entries.nextFile)) { - var installRDF = entry.clone(); - installRDF.append(FILE_INSTALL_MANIFEST); - - var chromeDir = entry.clone(); - chromeDir.append(DIR_CHROME); - - // It must be a directory without an install.rdf and it must contain - // a chrome directory - if (!entry.isDirectory() || installRDF.exists() || !chromeDir.exists()) - continue; - - var chromeEntries = chromeDir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator); - if (!chromeEntries.hasMoreElements()) - continue; - - // We're relying on the fact that there is only one JAR file - // in the "chrome" directory. This is a hack, but it works. - var jarFile = chromeEntries.nextFile; - if (jarFile.isDirectory()) - continue; - var id = location.getIDForLocation(entry); - - try { - var zipReader = getZipReaderForFile(jarFile); - zipReader.extract(FILE_INSTALL_MANIFEST, installRDF); - - var contentsManifestFile = location.getItemFile(id, FILE_CONTENTS_MANIFEST); - zipReader.extract(FILE_CONTENTS_MANIFEST, contentsManifestFile); - - var rootFiles = ["preview.png", "icon.png"]; - for (var i = 0; i < rootFiles.length; ++i) { - try { - var target = location.getItemFile(id, rootFiles[i]); - zipReader.extract(rootFiles[i], target); - } - catch (e) { - } - } - zipReader.close(); - } - catch (e) { - ERROR("ExtensionManager:_upgradeFromV10 - failed to extract theme files\r\n" + - "Exception: " + e); - } - } - } - - // When upgrading from a version 1.0 profile we need to populate the - // extensions datasource with all items before checking for incompatible - // items since the datasource hasn't been created yet. - var itemsToCheck = []; - if (this._checkForFileChanges()) { - // Create a list of all items that are to be installed so we can migrate - // these items's settings to the new datasource. - var items = PendingOperations.getOperations(OP_NEEDS_INSTALL); - for (i = items.length - 1; i >= 0; --i) { - if (items[i].locationKey == KEY_APP_PROFILE || - items[i].locationKey == KEY_APP_GLOBAL) - itemsToCheck.push(items[i].id); - } - this._finishOperations(); - } - - // If there are no items to migrate settings for return early. - if (itemsToCheck.length == 0) - return; - - var fileURL = getURLSpecFromFile(oldExtensionsFile); - var oldExtensionsDS = gRDF.GetDataSourceBlocking(fileURL); - var versionChecker = getVersionChecker(); - var ds = this.datasource; - var currAppVersion = gApp.version; - var currAppID = gApp.ID; - for (var i = 0; i < itemsToCheck.length; ++i) { - var item = ds.getItemForID(itemsToCheck[i]); - var oldPrefix = (item.type == Ci.nsIUpdateItem.TYPE_EXTENSION) ? PREFIX_EXTENSION : PREFIX_THEME; - var oldRes = gRDF.GetResource(oldPrefix + item.id); - // Disable the item if it was disabled in the version 1.0 extensions - // datasource. - if (oldExtensionsDS.GetTarget(oldRes, EM_R("disabled"), true)) - ds.setItemProperty(item.id, EM_R("userDisabled"), EM_L("true")); - - // app enable all items. If it is incompatible it will be app disabled - // later on. - ds.setItemProperty(item.id, EM_R("appDisabled"), null); - - // if the item is already compatible don't attempt to migrate the - // item's compatibility info - var newRes = getResourceForID(itemsToCheck[i]); - if (ds.isCompatible(ds, newRes)) - continue; - - var updatedMinVersion = null; - var updatedMaxVersion = null; - var targetApps = oldExtensionsDS.GetTargets(oldRes, EM_R("targetApplication"), true); - while (targetApps.hasMoreElements()) { - var targetApp = targetApps.getNext(); - if (targetApp instanceof Ci.nsIRDFResource) { - try { - var foundAppID = stringData(oldExtensionsDS.GetTarget(targetApp, EM_R("id"), true)); - // Different target application? (Note: v1.0 didn't support toolkit app ID) - if (foundAppID != currAppID) - continue; - - updatedMinVersion = stringData(oldExtensionsDS.GetTarget(targetApp, EM_R("minVersion"), true)); - updatedMaxVersion = stringData(oldExtensionsDS.GetTarget(targetApp, EM_R("maxVersion"), true)); - - // Only set the target app info if the extension's target app info - // in the version 1.0 extensions datasource makes it compatible - if (versionChecker.compare(currAppVersion, updatedMinVersion) >= 0 && - versionChecker.compare(currAppVersion, updatedMaxVersion) <= 0) - ds.setTargetApplicationInfo(item.id, foundAppID, updatedMinVersion, - updatedMaxVersion, null); - - break; - } - catch (e) { - } - } - } - } - }, - /** * Write the Extensions List and the Startup Cache * @param needsRestart