Bug 416205 - Update nsDownloadManager::Init from changes to mozIStorageService::OpenDatabase. r=Mardak, a=schrep

This commit is contained in:
sdwilsh@shawnwilsher.com 2008-02-09 11:10:06 -08:00
parent edb598a960
commit 12b86dd2ef

View File

@ -247,13 +247,22 @@ nsDownloadManager::InitDB(PRBool *aDoImport)
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = storage->OpenDatabase(dbFile, getter_AddRefs(mDBConn)); rv = storage->OpenDatabase(dbFile, getter_AddRefs(mDBConn));
if (rv == NS_ERROR_FILE_CORRUPTED) { NS_ENSURE_SUCCESS(rv, rv);
// delete and try again
rv = dbFile->Remove(PR_TRUE); PRBool ready;
(void)mDBConn->GetConnectionReady(&ready);
if (!ready) {
// delete and try again, since we don't care so much about losing a users
// download history
rv = dbFile->Remove(PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
rv = storage->OpenDatabase(dbFile, getter_AddRefs(mDBConn)); rv = storage->OpenDatabase(dbFile, getter_AddRefs(mDBConn));
NS_ENSURE_SUCCESS(rv, rv);
(void)mDBConn->GetConnectionReady(&ready);
if (!ready)
return NS_ERROR_UNEXPECTED;
} }
NS_ENSURE_SUCCESS(rv, rv);
PRBool tableExists; PRBool tableExists;
rv = mDBConn->TableExists(NS_LITERAL_CSTRING("moz_downloads"), &tableExists); rv = mDBConn->TableExists(NS_LITERAL_CSTRING("moz_downloads"), &tableExists);