зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1519060 - Places maintenance doesn't properly replace malformed databases. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D16199 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0965487e73
Коммит
08e5888d07
|
@ -1051,7 +1051,7 @@ ContentPrefService2.prototype = {
|
|||
let path = OS.Path.join(OS.Constants.Path.profileDir, "content-prefs.sqlite");
|
||||
let conn;
|
||||
let resetAndRetry = async e => {
|
||||
if (e.status != Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||
if (e.result != Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ var PlacesDBUtils = {
|
|||
logs.push(`The ${dbName} database is sane`);
|
||||
} catch (ex) {
|
||||
PlacesDBUtils.clearPendingTasks();
|
||||
if (ex.status == Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||
if (ex.result == Cr.NS_ERROR_FILE_CORRUPTED) {
|
||||
logs.push(`The ${dbName} database is corrupt`);
|
||||
Services.prefs.setCharPref("places.database.replaceDatabaseOnStartup", dbName);
|
||||
throw new Error(`Unable to fix corruption, ${dbName} will be replaced on next startup`);
|
||||
|
@ -1176,7 +1176,7 @@ async function integrity(dbName) {
|
|||
|
||||
// Create a new connection for this check, so we can operate independently
|
||||
// from a broken Places service.
|
||||
// openConnection returns an exception with .status == Cr.NS_ERROR_FILE_CORRUPTED,
|
||||
// openConnection returns an exception with .result == Cr.NS_ERROR_FILE_CORRUPTED,
|
||||
// we should do the same everywhere we want maintenance to try replacing the
|
||||
// database on next startup.
|
||||
let path = OS.Path.join(OS.Constants.Path.profileDir, dbName);
|
||||
|
@ -1190,16 +1190,14 @@ async function integrity(dbName) {
|
|||
try {
|
||||
await db.execute("REINDEX");
|
||||
} catch (ex) {
|
||||
let error = new Error("Impossible to reindex database");
|
||||
error.status = Cr.NS_ERROR_FILE_CORRUPTED;
|
||||
throw error;
|
||||
throw new Components.Exception("Impossible to reindex database",
|
||||
Cr.NS_ERROR_FILE_CORRUPTED);
|
||||
}
|
||||
|
||||
// Check again.
|
||||
if (!await check(db)) {
|
||||
let error = new Error("The database is still corrupt");
|
||||
error.status = Cr.NS_ERROR_FILE_CORRUPTED;
|
||||
throw error;
|
||||
throw new Components.Exception("The database is still corrupt",
|
||||
Cr.NS_ERROR_FILE_CORRUPTED);
|
||||
}
|
||||
} finally {
|
||||
await db.close();
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,13 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Tests that integrity check will replace a corrupt database.
|
||||
|
||||
add_task(async function() {
|
||||
await setupPlacesDatabase("corruptPayload.sqlite");
|
||||
await Assert.rejects(PlacesDBUtils.checkIntegrity(),
|
||||
/will be replaced on next startup/,
|
||||
"Should reject on corruption");
|
||||
Assert.equal(Services.prefs.getCharPref("places.database.replaceDatabaseOnStartup"),
|
||||
DB_FILENAME);
|
||||
});
|
|
@ -3,6 +3,7 @@ head = head.js
|
|||
firefox-appdir = browser
|
||||
support-files =
|
||||
corruptDB.sqlite
|
||||
corruptPayload.sqlite
|
||||
|
||||
[test_corrupt_favicons.js]
|
||||
[test_corrupt_favicons_schema.js]
|
||||
|
@ -10,6 +11,7 @@ support-files =
|
|||
[test_corrupt_telemetry.js]
|
||||
[test_favicons_replaceOnStartup.js]
|
||||
[test_favicons_replaceOnStartup_clone.js]
|
||||
[test_integrity_replacement.js]
|
||||
[test_places_replaceOnStartup.js]
|
||||
[test_places_replaceOnStartup_clone.js]
|
||||
[test_preventive_maintenance.js]
|
||||
|
|
Двоичные данные
toolkit/components/places/tests/migration/places_v43.sqlite
Двоичные данные
toolkit/components/places/tests/migration/places_v43.sqlite
Двоичный файл не отображается.
Двоичные данные
toolkit/components/places/tests/unit/missingBuiltIn.sqlite
Двоичные данные
toolkit/components/places/tests/unit/missingBuiltIn.sqlite
Двоичный файл не отображается.
|
@ -982,8 +982,8 @@ function openConnection(options) {
|
|||
Services.storage.openAsyncDatabase(file, dbOptions, (status, connection) => {
|
||||
if (!connection) {
|
||||
log.warn(`Could not open connection to ${path}: ${status}`);
|
||||
let error = new Error(`Could not open connection to ${path}: ${status}`);
|
||||
error.status = status;
|
||||
let error = new Components.Exception(`Could not open connection to ${path}: ${status}`,
|
||||
status);
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ add_task(async function test_open_normal_error() {
|
|||
|
||||
let openPromise = Sqlite.openConnection({path});
|
||||
await Assert.rejects(openPromise, reason => {
|
||||
return reason.status == Cr.NS_ERROR_FILE_CORRUPTED;
|
||||
return reason.result == Cr.NS_ERROR_FILE_CORRUPTED;
|
||||
}, "Check error status");
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче