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

Unified Diff: chrome/browser/chromeos/drive/file_cache.cc

Issue 54223003: drive: Recover cache entries from trashed DB to filter out non-dirty cache files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 2 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
« no previous file with comments | « chrome/browser/chromeos/drive/file_cache.h ('k') | chrome/browser/chromeos/drive/file_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/file_cache.cc
diff --git a/chrome/browser/chromeos/drive/file_cache.cc b/chrome/browser/chromeos/drive/file_cache.cc
index 276acb8b9fbe303498c8bf9ce530629e840cc321..ad7615c01f619b87cd7db38fbf41f008203a97d3 100644
--- a/chrome/browser/chromeos/drive/file_cache.cc
+++ b/chrome/browser/chromeos/drive/file_cache.cc
@@ -393,7 +393,8 @@ void FileCache::DestroyOnBlockingPool() {
}
bool FileCache::RecoverFilesFromCacheDirectory(
- const base::FilePath& dest_directory) {
+ const base::FilePath& dest_directory,
+ const std::map<std::string, FileCacheEntry>& recovered_cache_entries) {
int file_number = 1;
base::FileEnumerator enumerator(cache_file_directory_,
@@ -408,6 +409,22 @@ bool FileCache::RecoverFilesFromCacheDirectory(
continue;
}
+ // If a cache entry which is non-dirty and has matching MD5 is found in
+ // |recovered_cache_entries|, it means the current file is already uploaded
+ // to the server. Just delete it instead of recovering it.
+ std::map<std::string, FileCacheEntry>::const_iterator it =
+ recovered_cache_entries.find(id);
+ if (it != recovered_cache_entries.end()) {
+ const FileCacheEntry& recovered_entry = it->second;
+ // Due to the DB corruption, |recovered_entry| might be recovered from old
+ // revision. Perform MD5 check even when is_dirty() is false just in case.
+ if (!recovered_entry.is_dirty() &&
+ recovered_entry.md5() == util::GetMd5Digest(current)) {
+ base::DeleteFile(current, false /* recursive */);
+ continue;
+ }
+ }
+
// Read file contents to sniff mime type.
std::vector<char> content(net::kMaxBytesToSniff);
const int read_result =
« no previous file with comments | « chrome/browser/chromeos/drive/file_cache.h ('k') | chrome/browser/chromeos/drive/file_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698