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

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

Issue 2568743004: [Sync] Stop deleting LevelDB files when deleting Directory (Closed)
Patch Set: Only delete top level files in sync data folder. 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..31bf29247656757a7638a032fc5fe0a5d4a79aa0 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 chuild folders under
maxbogue 2016/12/20 00:54:06 child
skym 2016/12/20 16:12:45 Done.
+ // |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 the Sync Data folder.";
maxbogue 2016/12/20 00:54:06 Maybe "Could not delete all sync directory files."
skym 2016/12/20 16:12:45 Done.
+ }
+ }
+ }
+}
+
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