fix bug 197429 "clear disk cache broken on MacOS X". Rederive mCacheDirectory from parent after moving old mCacheDirectory to Cache.Trash for deletion, rather than operate on clone of mCacheDirectory. r=bryner sr=sfraser.

This commit is contained in:
gordon%netscape.com 2003-03-17 07:33:45 +00:00
parent c214ea9fc8
commit d8e0537dae
2 changed files with 17 additions and 5 deletions

View File

@ -53,6 +53,8 @@ CacheLogPrintPath(PRLogModuleLevel level, char * format, nsIFile * item)
nsresult rv = item->GetNativePath(path);
if (NS_SUCCEEDED(rv)) {
PR_LOG(gCacheLog, level, (format, path.get()));
} else {
PR_LOG(gCacheLog, level, ("GetNativePath failed: %x", rv));
}
}

View File

@ -1039,11 +1039,19 @@ nsDiskCacheDevice::MoveCacheToTrash(nsIFile ** result)
if (NS_FAILED(rv)) return rv;
// move cache directory into unique trash directory
nsCOMPtr<nsIFile> cacheDir;
rv = mCacheDirectory->Clone(getter_AddRefs(cacheDir));
nsCOMPtr<nsIFile> parentDir;
rv = mCacheDirectory->GetParent(getter_AddRefs(parentDir));
if (NS_FAILED(rv)) return rv;
rv = cacheDir->MoveToNative(uniqueDir, nsCString());
rv = mCacheDirectory->MoveToNative(uniqueDir, nsCString());
if (NS_FAILED(rv)) return rv;
// set mCacheDirectory to point to parentDir/Cache/ again
rv = parentDir->AppendNative(NS_LITERAL_CSTRING("Cache"));
if (NS_FAILED(rv)) return rv;
mCacheDirectory = do_QueryInterface(parentDir);
// return unique directory, in case caller wants specifically delete it
if (result)
@ -1058,8 +1066,10 @@ nsDiskCacheDevice::InitializeCacheDirectory()
nsresult rv;
rv = mCacheDirectory->Create(nsIFile::DIRECTORY_TYPE, 0777);
if (NS_FAILED(rv)) return rv;
CACHE_LOG_PATH(PR_LOG_ALWAYS, "\ncreate cache directory: %s\n", mCacheDirectory);
CACHE_LOG_ALWAYS(("mCacheDirectory->Create() = %x\n", rv));
if (NS_FAILED(rv)) return rv;
// reopen the cache map
rv = mCacheMap->Open(mCacheDirectory);
return rv;