Bug 559800: Extensions.sqlite doesn't get properly recreated if it is deleted. r=robstrong

This commit is contained in:
Dave Townsend 2010-04-20 15:33:00 -07:00
Родитель 4d8ef9957e
Коммит a01c1c31ef
2 изменённых файлов: 78 добавлений и 2 удалений

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

@ -1493,10 +1493,17 @@ var XPIProvider = {
}
else {
// If the database exists then the previous file cache can be trusted
// otherwise create an empty database
let db = FileUtils.getFile(KEY_PROFILEDIR, [FILE_DATABASE], true);
if (db.exists())
if (db.exists()) {
cache = Prefs.getCharPref(PREF_INSTALL_CACHE, null);
}
}
else {
LOG("Database is missing, recreating");
XPIDatabase.openConnection();
XPIDatabase.createSchema();
}
}
// Load the list of bootstrapped add-ons first so processFileChanges can
// modify it

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

@ -0,0 +1,69 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that deleting the database from the profile doesn't break
// anything
const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
var dest = profileDir.clone();
dest.append("addon1@tests.mozilla.org");
writeInstallRDFToDir({
id: "addon1@tests.mozilla.org",
version: "1.0",
updateURL: "http://localhost:4444/data/test_update.rdf",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}],
name: "Test Addon 1",
}, dest);
startupManager(1);
do_test_pending();
run_test_1();
}
function end_test() {
do_test_finished();
}
function run_test_1() {
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_eq(a1.version, "1.0");
let db = gProfD.clone();
db.append("extensions.sqlite");
db.remove(true);
shutdownManager();
// DB shutdown can be asynchronous, normally this isn't a problem but we
// can't delete it until it is closed.
do_execute_soon(check_test_1);
});
}
function check_test_1() {
startupManager(1, false);
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_eq(a1.version, "1.0");
let db = gProfD.clone();
db.append("extensions.sqlite");
do_check_true(db.exists());
do_check_true(db.fileSize > 0);
end_test();
});
}