Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4514)

Unified Diff: chrome/browser/sync/syncable/directory_backing_store.cc

Issue 1711006: Sync: Delete and recreate the sync database if its corrupt.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/syncable/directory_backing_store.cc
===================================================================
--- chrome/browser/sync/syncable/directory_backing_store.cc (revision 44692)
+++ chrome/browser/sync/syncable/directory_backing_store.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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,6 +12,7 @@
#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"
@@ -183,14 +184,16 @@
SQLStatement statement;
statement.prepare(*handle, "PRAGMA fullfsync = 1");
if (SQLITE_DONE != statement.step()) {
- LOG(FATAL) << sqlite3_errmsg(*handle);
+ LOG(ERROR) << sqlite3_errmsg(*handle);
+ return false;
}
}
{
SQLStatement statement;
statement.prepare(*handle, "PRAGMA synchronous = 2");
if (SQLITE_DONE != statement.step()) {
- LOG(FATAL) << sqlite3_errmsg(*handle);
+ LOG(ERROR) << sqlite3_errmsg(*handle);
+ return false;
}
}
sqlite3_busy_timeout(*handle, kDirectoryBackingStoreBusyTimeoutMs);
@@ -229,6 +232,13 @@
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_);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698