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

Unified Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 2862943002: SimpleCache: try to recover on CreateEntry on missing cache dir (Closed)
Patch Set: Rebase Created 3 years, 7 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 | « net/disk_cache/entry_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_synchronous_entry.cc
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index ea83472455e9170d7f0bb178fa6ee934bb09d6fd..2b4673c2384d29ff8082a912c0c441404daca107 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -868,8 +868,19 @@ bool SimpleSynchronousEntry::MaybeCreateFile(
int flags = File::FLAG_CREATE | File::FLAG_READ | File::FLAG_WRITE |
File::FLAG_SHARE_DELETE;
files_[file_index].Initialize(filename, flags);
- *out_error = files_[file_index].error_details();
+ // It's possible that the creation failed because someone deleted the
+ // directory (e.g. because someone pressed "clear cache" on Android).
+ // If so, we would keep failing for a while until periodic index snapshot
+ // re-creates the cache dir, so try to recover from it quickly here.
+ if (!files_[file_index].IsValid() &&
+ files_[file_index].error_details() == File::FILE_ERROR_NOT_FOUND &&
+ !base::DirectoryExists(path_)) {
+ if (base::CreateDirectory(path_))
+ files_[file_index].Initialize(filename, flags);
+ }
+
+ *out_error = files_[file_index].error_details();
empty_file_omitted_[file_index] = false;
return files_[file_index].IsValid();
« no previous file with comments | « net/disk_cache/entry_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698