Bug 1369051 - Assertion failure: !entry || !entry->IsFresh() in CacheIndex::UpdateIndex, r=honzab

This commit is contained in:
Michal Novotny 2017-08-11 12:30:59 +02:00
parent 8e8d4fdf49
commit 5d80c6450d

View File

@ -2806,11 +2806,16 @@ CacheIndex::BuildIndex()
return;
}
bool fileExists = false;
nsCOMPtr<nsIFile> file;
{
// Do not do IO under the lock.
StaticMutexAutoUnlock unlock(sLock);
rv = mDirEnumerator->GetNextFile(getter_AddRefs(file));
if (file) {
file->Exists(&fileExists);
}
}
if (mState == SHUTDOWN) {
return;
@ -2829,6 +2834,12 @@ CacheIndex::BuildIndex()
continue;
}
if (!fileExists) {
LOG(("CacheIndex::BuildIndex() - File returned by the iterator was "
"removed in the meantime [name=%s]", leaf.get()));
continue;
}
SHA1Sum::Hash hash;
rv = CacheFileIOManager::StrToHash(leaf, &hash);
if (NS_FAILED(rv)) {
@ -2902,6 +2913,7 @@ CacheIndex::BuildIndex()
LOG(("CacheIndex::BuildIndex() - CacheFile::InitEntryFromDiskData() "
"failed, removing file. [name=%s]", leaf.get()));
file->Remove(false);
entry->MarkRemoved();
} else {
LOG(("CacheIndex::BuildIndex() - Added entry to index. [name=%s]",
leaf.get()));
@ -3023,11 +3035,16 @@ CacheIndex::UpdateIndex()
return;
}
bool fileExists = false;
nsCOMPtr<nsIFile> file;
{
// Do not do IO under the lock.
StaticMutexAutoUnlock unlock(sLock);
rv = mDirEnumerator->GetNextFile(getter_AddRefs(file));
if (file) {
file->Exists(&fileExists);
}
}
if (mState == SHUTDOWN) {
return;
@ -3046,6 +3063,12 @@ CacheIndex::UpdateIndex()
continue;
}
if (!fileExists) {
LOG(("CacheIndex::UpdateIndex() - File returned by the iterator was "
"removed in the meantime [name=%s]", leaf.get()));
continue;
}
SHA1Sum::Hash hash;
rv = CacheFileIOManager::StrToHash(leaf, &hash);
if (NS_FAILED(rv)) {