Bug 1120945 - HTTP cache v2: maximum number of entries is limited to 13106 on FAT32, r=honzab

This commit is contained in:
Michal Novotny 2015-01-27 02:29:02 +01:00
parent babd5741c6
commit 9e0728ef38

View File

@ -3596,6 +3596,30 @@ CacheFileIOManager::OpenNSPRHandle(CacheFileHandle *aHandle, bool aCreate)
if (aCreate) {
rv = aHandle->mFile->OpenNSPRFileDesc(
PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 0600, &aHandle->mFD);
if (rv == NS_ERROR_FILE_NO_DEVICE_SPACE) {
LOG(("CacheFileIOManager::OpenNSPRHandle() - Cannot create a new file, we"
" might reached a limit on FAT32. Will evict a single entry and try "
"again. [hash=%08x%08x%08x%08x%08x]", LOGSHA1(aHandle->Hash())));
SHA1Sum::Hash hash;
uint32_t cnt;
rv = CacheIndex::GetEntryForEviction(&hash, &cnt);
if (NS_SUCCEEDED(rv)) {
rv = DoomFileByKeyInternal(&hash, true);
}
if (NS_SUCCEEDED(rv)) {
rv = aHandle->mFile->OpenNSPRFileDesc(
PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 0600, &aHandle->mFD);
LOG(("CacheFileIOManager::OpenNSPRHandle() - Successfully evicted entry"
" with hash %08x%08x%08x%08x%08x. %s to create the new file.",
LOGSHA1(&hash), NS_SUCCEEDED(rv) ? "Succeeded" : "Failed"));
} else {
LOG(("CacheFileIOManager::OpenNSPRHandle() - Couldn't evict an existing"
" entry."));
rv = NS_ERROR_FILE_NO_DEVICE_SPACE;
}
}
NS_ENSURE_SUCCESS(rv, rv);
aHandle->mFileExists = true;