Chromium Code Reviews| 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; |
| } |