mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
bug 251625 - .part files not removed when cancelling download. r=bsmedberg, a=chofmann
This commit is contained in:
parent
2cdc4a0b63
commit
62da1d290d
@ -711,12 +711,28 @@ nsDownloadManager::CancelDownload(const PRUnichar* aPath)
|
||||
|
||||
internalDownload->SetDownloadState(nsIDownloadManager::DOWNLOAD_CANCELED);
|
||||
|
||||
// xxxmpc - this is a bit of a hack to delete the .part file
|
||||
// created in nsExternalHelperAppService.cpp
|
||||
nsCOMPtr<nsILocalFile> targetFile;
|
||||
rv = internalDownload->GetTargetFile(getter_AddRefs(targetFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString leafName;
|
||||
targetFile->GetLeafName(leafName);
|
||||
leafName.Append(NS_LITERAL_STRING(".part"));
|
||||
targetFile->SetLeafName(leafName);
|
||||
|
||||
PRBool exists;
|
||||
targetFile->Exists(&exists);
|
||||
if (exists)
|
||||
targetFile->Remove(PR_FALSE);
|
||||
|
||||
// Cancel using the provided object
|
||||
nsCOMPtr<nsICancelable> cancelable;
|
||||
internalDownload->GetCancelable(getter_AddRefs(cancelable));
|
||||
if (cancelable)
|
||||
cancelable->Cancel(NS_BINDING_ABORTED);
|
||||
|
||||
|
||||
DownloadEnded(aPath, nsnull);
|
||||
|
||||
gObserverService->NotifyObservers(internalDownload, "dl-cancel", nsnull);
|
||||
@ -730,7 +746,7 @@ nsDownloadManager::CancelDownload(const PRUnichar* aPath)
|
||||
rv = observer->Observe(internalDownload, "oncancel", nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user