mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 19:09:49 +00:00
Bug 593815 - Remove all files left behind when a download is canceled. [r=sdwilsh, sr=bz, a=blocker]
--HG-- extra : rebase_source : e70063c968a1a85ff6a9813af2c42a8c44e676e6
This commit is contained in:
parent
461a2eb686
commit
b2a94d75f0
@ -1516,6 +1516,15 @@ nsDownloadManager::CancelDownload(PRUint32 aID)
|
||||
dl->mTempFile->Remove(PR_FALSE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
if (NS_SUCCEEDED(dl->GetTargetFile(getter_AddRefs(file))))
|
||||
{
|
||||
PRBool exists;
|
||||
file->Exists(&exists);
|
||||
if (exists)
|
||||
file->Remove(PR_FALSE);
|
||||
}
|
||||
|
||||
nsresult rv = dl->SetState(nsIDownloadManager::DOWNLOAD_CANCELED);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -2775,12 +2784,6 @@ nsDownload::OpenWithApplication()
|
||||
nsresult rv = GetTargetFile(getter_AddRefs(target));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make sure the suggested name is unique since in this case we don't
|
||||
// have a file name that was guaranteed to be unique by going through
|
||||
// the File Save dialog
|
||||
rv = target->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Move the temporary file to the target location
|
||||
rv = MoveTempToTarget();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -2352,7 +2352,7 @@ nsresult nsExternalAppHandler::OpenWithApplication()
|
||||
if (deleteTempFileOnExit || gExtProtSvc->InPrivateBrowsing())
|
||||
mFinalFileDestination->SetPermissions(0400);
|
||||
|
||||
rv = mMimeInfo->LaunchWithFile(mFinalFileDestination);
|
||||
rv = mMimeInfo->LaunchWithFile(mFinalFileDestination);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
// Send error notification.
|
||||
@ -2483,6 +2483,13 @@ NS_IMETHODIMP nsExternalAppHandler::Cancel(nsresult aReason)
|
||||
mTempFile = nsnull;
|
||||
}
|
||||
|
||||
// If we have already created a final destination file, we remove it as well
|
||||
if (mFinalFileDestination)
|
||||
{
|
||||
mFinalFileDestination->Remove(PR_FALSE);
|
||||
mFinalFileDestination = nsnull;
|
||||
}
|
||||
|
||||
// Release the listener, to break the reference cycle with it (we are the
|
||||
// observer of the listener).
|
||||
mWebProgressListener = nsnull;
|
||||
|
Loading…
x
Reference in New Issue
Block a user