Chromium Code Reviews| 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..c4f85c3dbe7dbd42c55559e9dc074a8a092e05fa 100644 |
| --- a/net/disk_cache/simple/simple_synchronous_entry.cc |
| +++ b/net/disk_cache/simple/simple_synchronous_entry.cc |
| @@ -868,8 +868,18 @@ 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_) && base::CreateDirectory(path_)) { |
| + files_[file_index].Initialize(filename, flags); |
|
jkarlin
2017/05/05 17:16:21
I worry a bit about the state of the cache being s
pasko
2017/05/05 17:24:15
Writing index here would probably fix the issue, b
jkarlin
2017/05/05 17:42:18
Okay, works with me.
|
| + } |
| + |
| + *out_error = files_[file_index].error_details(); |
| empty_file_omitted_[file_index] = false; |
| return files_[file_index].IsValid(); |