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

Unified Diff: google_apis/gcm/engine/gcm_store_impl.cc

Issue 2380003002: GCM Store: Fix invalid argument errors (Closed)
Patch Set: Fix Win compile with FILE_PATH_LITERAL Created 4 years, 3 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
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..59600a1152460bcf99a344a9f174c7568e60143c 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -178,6 +178,13 @@ 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::PathExists(path.Append(FILE_PATH_LITERAL("CURRENT")));
+}
+
} // namespace
class GCMStoreImpl::Backend
@@ -287,7 +294,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;
}
« no previous file with comments | « components/gcm_driver/gcm_client_impl_unittest.cc ('k') | google_apis/gcm/engine/gcm_store_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698