Chromium Code Reviews| Index: google_apis/gcm/engine/gcm_store_impl.cc |
| diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc |
| index 1ed91a9b8f095a70d7a4f07725edc70a537a50d2..3c8c260fe31ba1aa786bb450138b4ee12e8b92ca 100644 |
| --- a/google_apis/gcm/engine/gcm_store_impl.cc |
| +++ b/google_apis/gcm/engine/gcm_store_impl.cc |
| @@ -178,6 +178,14 @@ leveldb::Slice MakeSlice(const base::StringPiece& s) { |
| return leveldb::Slice(s.begin(), s.size()); |
| } |
| +bool DatabaseExists(const base::FilePath& path) { |
| + // It's not enough to check that the directory exists, since DestroyDB |
| + // sometimes leaves behind an empty directory |
| + // (https://github.com/google/leveldb/issues/215). |
| + return base::DirectoryExists(path) && |
| + base::PathExists(path.Append("CURRENT")); |
|
Nicolas Zea
2016/09/29 16:49:57
is PathExists sufficient? Do we still need Directo
johnme
2016/09/29 17:08:29
Done (yeah, I was just trying to be explicit, but
|
| +} |
| + |
| } // namespace |
| class GCMStoreImpl::Backend |
| @@ -287,7 +295,7 @@ LoadStatus GCMStoreImpl::Backend::OpenStoreAndLoadData(StoreOpenMode open_mode, |
| // Checks if the store exists or not. Calling DB::Open with create_if_missing |
| // not set will still create a new directory if the store does not exist. |
| - if (open_mode == DO_NOT_CREATE && !base::DirectoryExists(path_)) { |
| + if (open_mode == DO_NOT_CREATE && !DatabaseExists(path_)) { |
| DVLOG(2) << "Database " << path_.value() << " does not exist"; |
| return STORE_DOES_NOT_EXIST; |
| } |