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

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

Issue 8475017: Check node references during sync DB init (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments Created 9 years, 1 month 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 | « chrome/browser/sync/syncable/dir_open_result.h ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/syncable/directory_manager.cc
diff --git a/chrome/browser/sync/syncable/directory_manager.cc b/chrome/browser/sync/syncable/directory_manager.cc
index b98aacbd3d7c7a237d908bc6c7a107c2c63fc9df..9b420a53486e7b85b51c2a5fd831d014b1e1bc02 100644
--- a/chrome/browser/sync/syncable/directory_manager.cc
+++ b/chrome/browser/sync/syncable/directory_manager.cc
@@ -8,6 +8,7 @@
#include <set>
#include <iterator>
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/port.h"
@@ -72,11 +73,23 @@ DirOpenResult DirectoryManager::OpenImpl(const std::string& name,
// Otherwise, open it.
scoped_ptr<Directory> dir(new Directory);
- const DirOpenResult result = dir->Open(path, name, delegate);
+ DirOpenResult result = dir->Open(path, name, delegate);
+
+ if (syncable::FAILED_LOGICAL_CORRUPTION == result) {
+ // In this case, wipe out the directory and try again.
+ VLOG(ERROR) << "Database consistency checks failed. "
+ << "Will re-create sync database at "
+ << path.LossyDisplayName();
+ dir.reset(new Directory);
tim (not reviewing) 2011/11/17 18:39:57 style nit - use Directory()
+ file_util::Delete(path, false);
+ result = dir->Open(path, name, delegate);
+ }
+
if (syncable::OPENED == result) {
base::AutoLock lock(lock_);
managed_directory_ = dir.release();
}
+
return result;
}
« no previous file with comments | « chrome/browser/sync/syncable/dir_open_result.h ('k') | chrome/browser/sync/syncable/syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698