summaryrefslogtreecommitdiffstats
path: root/webkit/database/database_tracker.cc
diff options
context:
space:
mode:
authordumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 22:40:46 +0000
committerdumi@chromium.org <dumi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 22:40:46 +0000
commitc35e81aa6c62eaea2f66bf00fe02b58ede8cbecd (patch)
tree2799d96ebdf3e759a1a0f2272ea2cc238b748d72 /webkit/database/database_tracker.cc
parent4f1b94fe2cb294b919d6a761f0accc155e7a8b8b (diff)
downloadchromium_src-c35e81aa6c62eaea2f66bf00fe02b58ede8cbecd.zip
chromium_src-c35e81aa6c62eaea2f66bf00fe02b58ede8cbecd.tar.gz
chromium_src-c35e81aa6c62eaea2f66bf00fe02b58ede8cbecd.tar.bz2
Deleting the 'databases' directory if the tracker database exists but
is corrupt or doesn't have a meta table. BUG=none TEST=none Review URL: http://codereview.chromium.org/377018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/database/database_tracker.cc')
-rw-r--r--webkit/database/database_tracker.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc
index 1edf0bf..c529c28 100644
--- a/webkit/database/database_tracker.cc
+++ b/webkit/database/database_tracker.cc
@@ -102,11 +102,25 @@ FilePath DatabaseTracker::GetFullDBFilePath(
bool DatabaseTracker::LazyInit() {
if (!initialized_) {
+ // If the tracker database exists, but it's corrupt or doesn't
+ // have a meta table, delete the database directory
+ const FilePath kTrackerDatabaseFullPath =
+ db_dir_.Append(FilePath(kTrackerDatabaseFileName));
+ if (file_util::DirectoryExists(db_dir_) &&
+ file_util::PathExists(kTrackerDatabaseFullPath) &&
+ (!db_->Open(kTrackerDatabaseFullPath) ||
+ !db_->DoesTableExist("meta"))) {
+ db_->Close();
+ if (!file_util::Delete(db_dir_, true))
+ return false;
+ }
+
databases_table_.reset(new DatabasesTable(db_.get()));
meta_table_.reset(new sql::MetaTable());
+
initialized_ =
file_util::CreateDirectory(db_dir_) &&
- db_->Open(db_dir_.Append(FilePath(kTrackerDatabaseFileName))) &&
+ db_->Open(kTrackerDatabaseFullPath) &&
meta_table_->Init(db_.get(), kCurrentVersion, kCompatibleVersion) &&
(meta_table_->GetCompatibleVersionNumber() <= kCurrentVersion) &&
databases_table_->Init();