Bug 1425146 - P1 - Ensure the schema for the cache.sqlite is up to date beforing accessing it; r=janv

Bug 1290481 introduces the padding mechanism, but there was a corner case which
weren't handled correctly. It created a chance to access cache database before
acutally checking the database version and schema upgrade. If the schema of
cache.sqlite is too old and the padding file disappear, it breaks origins
initialization. This patch ensure the schema is updated to the newest before
accessing it.
This commit is contained in:
Tom Tung committed 2018-09-07 10:28:30 +02:00
1 parent 7fb7d6c77e
commit 1870598d40
1 file changed
+8
+8
View File
@@ -90,6 +90,14 @@ LockedGetPaddingSizeFromDB(nsIFile* aDir, const nsACString& aGroup,
}
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
// Make sure that the database has the latest schema before we try to read
// from it. We have to do this because LockedGetPaddingSizeFromDB is called
// by QuotaClient::GetUsageForOrigin which may run at any time (there's no
// guarantee that SetupAction::RunSyncWithDBOnTarget already checked the
// schema for the given origin).
rv = mozilla::dom::cache::db::CreateOrMigrateSchema(conn);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
int64_t paddingSize = 0;
rv = mozilla::dom::cache::
LockedDirectoryPaddingRestore(aDir, conn, /* aMustRestore */ false,