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

Unified Diff: components/sync/syncable/directory.cc

Issue 2568743004: [Sync] Stop deleting LevelDB files when deleting Directory (Closed)
Patch Set: Updated for Max's comments. Created 4 years 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 | « components/sync/syncable/directory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/syncable/directory.cc
diff --git a/components/sync/syncable/directory.cc b/components/sync/syncable/directory.cc
index 42fd457bc24b81b35816b68cd3b36cb4f32882b1..d8f708ed8defdb504e69e9f886c3b6bc8e2fa265 100644
--- a/components/sync/syncable/directory.cc
+++ b/components/sync/syncable/directory.cc
@@ -11,7 +11,9 @@
#include <utility>
#include "base/base64.h"
+#include "base/files/file_enumerator.h"
#include "base/guid.h"
+#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h"
@@ -432,6 +434,23 @@ bool Directory::ReindexParentId(BaseWriteTransaction* trans,
return true;
}
+// static
+void Directory::DeleteDirectoryFiles(const base::FilePath& directory_path) {
+ // We assume that the directory database files are all top level files, and
+ // use no folders. We also assume that there might be child folders under
+ // |directory_path| that are used for non-directory things, like storing
+ // ModelTypeStore/LevelDB data, and we expressly do not want to delete those.
+ if (base::DirectoryExists(directory_path)) {
+ base::FileEnumerator fe(directory_path, false, base::FileEnumerator::FILES);
+ for (base::FilePath current = fe.Next(); !current.empty();
+ current = fe.Next()) {
+ if (!base::DeleteFile(current, false)) {
+ LOG(DFATAL) << "Could not delete all sync directory files.";
+ }
+ }
+ }
+}
+
void Directory::RemoveFromAttachmentIndex(
const ScopedKernelLock& lock,
const int64_t metahandle,
« no previous file with comments | « components/sync/syncable/directory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698