mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix crash if a paused download is stopped (bug 395188); patch by Mardak, r=sdwilsh, a=dsicore
This commit is contained in:
parent
88c81d41b4
commit
f8715616ef
@ -150,7 +150,10 @@ nsDownloadManager::CompleteDownload(nsDownload *aDownload)
|
||||
// we've stopped, so break the cycle we created at download start
|
||||
aDownload->mCancelable = nsnull;
|
||||
aDownload->mEntityID.Truncate();
|
||||
if (aDownload->mWasResumed)
|
||||
|
||||
// we need do what exthandler would have done for a finished download
|
||||
if (aDownload->mDownloadState == nsIDownloadManager::DOWNLOAD_FINISHED &&
|
||||
aDownload->mWasResumed)
|
||||
(void)ExecuteDesiredAction(aDownload);
|
||||
|
||||
(void)mCurrentDownloads.RemoveObject(aDownload);
|
||||
@ -161,9 +164,14 @@ nsDownloadManager::ExecuteDesiredAction(nsDownload *aDownload)
|
||||
{
|
||||
// If we have a temp file and we have resumed, we have to do what the external
|
||||
// helper app service would have done.
|
||||
if (!aDownload->mTempFile && !aDownload->mWasResumed)
|
||||
if (!aDownload->mTempFile || !aDownload->mWasResumed)
|
||||
return NS_OK;
|
||||
|
||||
// We need to bail if for some reason the temp file got removed
|
||||
PRBool fileExists;
|
||||
if (NS_FAILED(aDownload->mTempFile->Exists(&fileExists)) || !fileExists)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Find out if it was a SaveToDisk kind of a download
|
||||
nsHandlerInfoAction action = nsIMIMEInfo::saveToDisk;
|
||||
nsresult rv;
|
||||
@ -183,7 +191,6 @@ nsDownloadManager::ExecuteDesiredAction(nsDownload *aDownload)
|
||||
// MoveTo will fail if the file already exists, but we've already
|
||||
// obtained confirmation from the user that this is OK. So, we have
|
||||
// to remove it if it exists.
|
||||
PRBool fileExists;
|
||||
if (NS_SUCCEEDED(target->Exists(&fileExists)) && fileExists) {
|
||||
rv = target->Remove(PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
Loading…
Reference in New Issue
Block a user