author | Mark Hammond <mhammond@skippinet.com.au> |
Mon, 18 Jul 2016 09:55:00 +1000 | |
changeset 305525 | 2d1ef80b6820e79ee63799e895503ee291245ea1 |
parent 305524 | a10527539339290247c0f7c9dc41896a5b0dd67e |
child 305526 | 77e960d65f6422b5c55d5c33e257066f59b5b8e1 |
push id | 30707 |
push user | mhammond@skippinet.com.au |
push date | Wed, 20 Jul 2016 04:08:25 +0000 |
treeherder | autoland@2d1ef80b6820 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | rhelmer |
bugs | 1286785 |
milestone | 50.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
toolkit/mozapps/extensions/internal/AddonRepository.jsm | file | annotate | diff | comparison | revisions |
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm +++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm @@ -474,23 +474,16 @@ AddonSearchResult.prototype = { * that are compatible with the current application and are not already * installed. */ this.AddonRepository = { /** * Whether caching is currently enabled */ get cacheEnabled() { - // Act as though caching is disabled if there was an unrecoverable error - // openning the database. - if (!AddonDatabase.databaseOk) { - logger.warn("Cache is disabled because database is not OK"); - return false; - } - let preference = PREF_GETADDONS_CACHE_ENABLED; let enabled = false; try { enabled = Services.prefs.getBoolPref(preference); } catch(e) { logger.warn("cacheEnabled: Couldn't get pref: " + preference); } @@ -1556,19 +1549,16 @@ this.AddonRepository = { }, flush: function() { return AddonDatabase.flush(); } }; var AddonDatabase = { - // false if there was an unrecoverable error opening the database - databaseOk: true, - connectionPromise: null, // the in-memory database DB: BLANK_DB(), /** * A getter to retrieve the path to the DB */ get jsonFile() { @@ -1604,41 +1594,40 @@ var AddonDatabase = { if (!Number.isInteger(schema) || schema < DB_MIN_JSON_SCHEMA) { throw new Error("Invalid schema value."); } } catch (e) { if (e instanceof OS.File.Error && e.becauseNoSuchFile) { logger.debug("No " + FILE_DATABASE + " found."); - - // Create a blank addons.json file - this._saveDBToDisk(); + } else { + logger.error(`Malformed ${FILE_DATABASE}: ${e} - resetting to empty`); + } - let dbSchema = 0; - try { - dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA); - } catch (e) {} + // Create a blank addons.json file + this._saveDBToDisk(); - if (dbSchema < DB_MIN_JSON_SCHEMA) { - let results = yield new Promise((resolve, reject) => { - AddonRepository_SQLiteMigrator.migrate(resolve); - }); + let dbSchema = 0; + try { + dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA); + } catch (e) {} - if (results.length) { - yield this._insertAddons(results); - } + if (dbSchema < DB_MIN_JSON_SCHEMA) { + let results = yield new Promise((resolve, reject) => { + AddonRepository_SQLiteMigrator.migrate(resolve); + }); + if (results.length) { + yield this._insertAddons(results); } - Services.prefs.setIntPref(PREF_GETADDONS_DB_SCHEMA, DB_SCHEMA); - } else { - logger.error("Malformed " + FILE_DATABASE + ": " + e); - this.databaseOk = false; } + + Services.prefs.setIntPref(PREF_GETADDONS_DB_SCHEMA, DB_SCHEMA); return this.DB; } Services.prefs.setIntPref(PREF_GETADDONS_DB_SCHEMA, DB_SCHEMA); // We use _insertAddon manually instead of calling // insertAddons to avoid the write to disk which would // be a waste since this is the data that was just read. @@ -1666,18 +1655,16 @@ var AddonDatabase = { * * @param aCallback * An optional callback to call once complete * @param aSkipFlush * An optional boolean to skip flushing data to disk. Useful * when the database is going to be deleted afterwards. */ shutdown: function(aSkipFlush) { - this.databaseOk = true; - if (!this.connectionPromise) { return Promise.resolve(); } this.connectionPromise = null; if (aSkipFlush) { return Promise.resolve();