summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 01:24:55 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 01:24:55 +0000
commita3b52885c4d2e91e05c92b29904c35279b3f3e6c (patch)
tree1c0bf41d036bfc8dd8c019b059e5d51aa042f524
parente12b72b0056fb4c0a5d57591f962c376e8d3a6d7 (diff)
downloadchromium_src-a3b52885c4d2e91e05c92b29904c35279b3f3e6c.zip
chromium_src-a3b52885c4d2e91e05c92b29904c35279b3f3e6c.tar.gz
chromium_src-a3b52885c4d2e91e05c92b29904c35279b3f3e6c.tar.bz2
Revert 45257 - Delete and recreate the sync database if it is corrupt.
BUG=40020 TEST=DirectoryBackingStoreTest.Corruption Review URL: http://codereview.chromium.org/1733008 TBR=albertb@chromium.org Review URL: http://codereview.chromium.org/1733009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45272 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/syncable/directory_backing_store.cc16
-rw-r--r--chrome/browser/sync/syncable/directory_backing_store.h3
-rw-r--r--chrome/browser/sync/syncable/directory_backing_store_unittest.cc23
3 files changed, 4 insertions, 38 deletions
diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc
index ee54d69..9d10c24 100644
--- a/chrome/browser/sync/syncable/directory_backing_store.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,7 +12,6 @@
#include <limits>
-#include "base/file_util.h"
#include "base/hash_tables.h"
#include "base/logging.h"
#include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
@@ -184,16 +183,14 @@ bool DirectoryBackingStore::OpenAndConfigureHandleHelper(
SQLStatement statement;
statement.prepare(*handle, "PRAGMA fullfsync = 1");
if (SQLITE_DONE != statement.step()) {
- LOG(ERROR) << sqlite3_errmsg(*handle);
- return false;
+ LOG(FATAL) << sqlite3_errmsg(*handle);
}
}
{
SQLStatement statement;
statement.prepare(*handle, "PRAGMA synchronous = 2");
if (SQLITE_DONE != statement.step()) {
- LOG(ERROR) << sqlite3_errmsg(*handle);
- return false;
+ LOG(FATAL) << sqlite3_errmsg(*handle);
}
}
sqlite3_busy_timeout(*handle, kDirectoryBackingStoreBusyTimeoutMs);
@@ -232,13 +229,6 @@ DirOpenResult DirectoryBackingStore::Load(MetahandlesIndex* entry_bucket,
bool DirectoryBackingStore::BeginLoad() {
DCHECK(load_dbhandle_ == NULL);
- bool ret = OpenAndConfigureHandleHelper(&load_dbhandle_);
- if (ret)
- return ret;
- // Something's gone wrong. Nuke the database and try again.
- LOG(ERROR) << "Sync database " << backing_filepath_.value()
- << " corrupt. Deleting and recreating.";
- file_util::Delete(backing_filepath_, false);
return OpenAndConfigureHandleHelper(&load_dbhandle_);
}
diff --git a/chrome/browser/sync/syncable/directory_backing_store.h b/chrome/browser/sync/syncable/directory_backing_store.h
index d1e7d7d..34cb3ac 100644
--- a/chrome/browser/sync/syncable/directory_backing_store.h
+++ b/chrome/browser/sync/syncable/directory_backing_store.h
@@ -81,7 +81,6 @@ class DirectoryBackingStore {
FRIEND_TEST(DirectoryBackingStoreTest, MigrateVersion69To70);
FRIEND_TEST(DirectoryBackingStoreTest, MigrateVersion70To71);
FRIEND_TEST(DirectoryBackingStoreTest, ModelTypeIds);
- FRIEND_TEST(DirectoryBackingStoreTest, Corruption);
FRIEND_TEST(MigrationTest, ToCurrentVersion);
// General Directory initialization and load helpers.
@@ -149,7 +148,7 @@ class DirectoryBackingStore {
int GetVersion();
bool MigrateToSpecifics(const char* old_columns,
const char* specifics_column,
- void (*handler_function) (
+ void (*handler_function)(
SQLStatement* old_value_query,
int old_value_column,
sync_pb::EntitySpecifics* mutable_new_value));
diff --git a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
index b15c09d..bf5dfde 100644
--- a/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store_unittest.cc
@@ -10,7 +10,6 @@
#include "app/sql/statement.h"
#include "app/sql/transaction.h"
#include "base/file_path.h"
-#include "base/file_util.h"
#include "base/scoped_ptr.h"
#include "base/scoped_temp_dir.h"
#include "base/stl_util-inl.h"
@@ -871,26 +870,4 @@ TEST_F(DirectoryBackingStoreTest, ModelTypeIds) {
}
}
-TEST_F(DirectoryBackingStoreTest, Corruption) {
- {
- scoped_ptr<DirectoryBackingStore> dbs(
- new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
- EXPECT_TRUE(dbs->BeginLoad());
- }
- std::string bad_data("BAD DATA");
- file_util::WriteFile(GetDatabasePath(), bad_data.data(), bad_data.size());
- {
- scoped_ptr<DirectoryBackingStore> dbs(
- new DirectoryBackingStore(GetUsername(), GetDatabasePath()));
-
- // In release mode, we expect the sync database to nuke itself and start
- // over if it detects invalid/corrupted data.
-#if defined(NDEBUG)
- EXPECT_TRUE(dbs->BeginLoad());
-#else
- EXPECT_DEATH(dbs->BeginLoad(), "sqlite error");
-#endif
- }
-}
-
} // namespace syncable