Index: net/disk_cache/simple/simple_index_file.cc |
diff --git a/net/disk_cache/simple/simple_index_file.cc b/net/disk_cache/simple/simple_index_file.cc |
index d31d2446c60914b64c73039a77881804fcddc1fe..56344cf6c9e564f937fc1644f607f429facf3685 100644 |
--- a/net/disk_cache/simple/simple_index_file.cc |
+++ b/net/disk_cache/simple/simple_index_file.cc |
@@ -160,14 +160,29 @@ void ProcessEntryFile(SimpleIndex::EntrySet* entries, |
SimpleIndex::EntrySet::iterator it = entries->find(hash_key); |
base::CheckedNumeric<uint32_t> total_entry_size = size; |
+ // When the entry size is nonsense we can't use it, since don't want to |
+ // crash, but we actually do want to proceed with the entry in the index: if |
+ // it's not in index, and is never accessed again, then the file will never |
+ // get removed. So we just make something up; if it's unused it will get |
pasko
2017/05/11 12:15:07
not really "never get removed", it will be removed
morlovich
2017/05/19 11:35:05
It would be never removed if we decided to skip ov
|
+ // kicked out eventually; if it's used we will either delete the file due to |
+ // file format error, or set this correctly. |
+ const int kPlaceHolderSizeWhenInvalid = 32768; |
pasko
2017/05/11 12:15:07
I think it's worth mentioning that the entry size
morlovich
2017/05/19 11:35:05
OK, will tweak the comment to make it more explici
Maks Orlovich
2017/05/19 13:18:06
Hmm, thinking some more, maybe we should range-che
pasko
2017/05/19 14:38:07
ah, you are right. That basically brings us back t
Maks Orlovich
2017/05/19 15:09:58
True, that would save work, but the check is proba
|
+ if (!total_entry_size.IsValid()) { |
+ LOG(WARNING) << "Invalid file size while restoring index from disk: " |
+ << size << " on file:" << file_name; |
+ } |
+ |
if (it == entries->end()) { |
SimpleIndex::InsertInEntrySet( |
- hash_key, EntryMetadata(last_used_time, total_entry_size.ValueOrDie()), |
+ hash_key, |
+ EntryMetadata(last_used_time, total_entry_size.ValueOrDefault( |
+ kPlaceHolderSizeWhenInvalid)), |
entries); |
} else { |
// Summing up the total size of the entry through all the *_[0-1] files |
total_entry_size += it->second.GetEntrySize(); |
- it->second.SetEntrySize(total_entry_size.ValueOrDie()); |
+ it->second.SetEntrySize( |
+ total_entry_size.ValueOrDefault(kPlaceHolderSizeWhenInvalid)); |
} |
} |