Bug 1119406 - HTTP cache v2: Doom cache entry when writing of metadata fails, r=honzab

This commit is contained in:
Michal Novotny 2015-01-27 15:50:18 +01:00
parent 374e2ca9d1
commit cdc4849d47
2 changed files with 6 additions and 1 deletions

View File

@ -612,8 +612,9 @@ CacheFile::OnMetadataWritten(nsresult aResult)
MOZ_ASSERT(!mMemoryOnly);
MOZ_ASSERT(!mOpeningFile);
if (NS_FAILED(aResult)) {
if (NS_WARN_IF(NS_FAILED(aResult))) {
// TODO close streams with an error ???
SetError(aResult);
}
if (mOutput || mInputs.Length() || mChunks.Count())

View File

@ -706,6 +706,10 @@ public:
} else {
rv = CacheFileIOManager::gInstance->WriteInternal(
mHandle, mOffset, mBuf, mCount, mValidate);
if (NS_FAILED(rv) && !mCallback) {
// No listener is going to handle the error, doom the file
CacheFileIOManager::gInstance->DoomFileInternal(mHandle);
}
}
MOZ_EVENT_TRACER_DONE(static_cast<nsIRunnable*>(this), "net::cache::write-background");