зеркало из https://github.com/mozilla/pjs.git
bug 251625 - take two, r+a=bsmedberg
This commit is contained in:
Родитель
7f83d40a3e
Коммит
1059a6678b
|
@ -535,6 +535,7 @@ nsDownloadManager::AddDownload(DownloadType aDownloadType,
|
|||
internalDownload->SetDownloadManager(this);
|
||||
internalDownload->SetTarget(aTarget);
|
||||
internalDownload->SetSource(aSource);
|
||||
internalDownload->SetTempFile(aTempFile);
|
||||
|
||||
// The path is the uniquifier of the download resource.
|
||||
// XXXben - this is a little risky - really we should be using anonymous
|
||||
|
@ -712,22 +713,6 @@ 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));
|
||||
|
@ -736,6 +721,16 @@ nsDownloadManager::CancelDownload(const PRUnichar* aPath)
|
|||
|
||||
DownloadEnded(aPath, nsnull);
|
||||
|
||||
// dump the temp file. This should really be done when the transfer
|
||||
// is cancelled, but there's other cancelallation causes that shouldn't
|
||||
// remove this, we need to improve those bits
|
||||
nsCOMPtr<nsILocalFile> tempFile;
|
||||
rv = internalDownload->GetTempFile(getter_AddRefs(tempFile));
|
||||
PRBool exists;
|
||||
tempFile->Exists(&exists);
|
||||
if (exists)
|
||||
tempFile->Remove(PR_FALSE);
|
||||
|
||||
gObserverService->NotifyObservers(internalDownload, "dl-cancel", nsnull);
|
||||
|
||||
// if there's a progress dialog open for the item,
|
||||
|
@ -1852,6 +1847,21 @@ nsDownload::GetDialog(nsIProgressDialog** aDialog)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDownload::SetTempFile(nsILocalFile* aTempFile)
|
||||
{
|
||||
mTempFile = aTempFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDownload::GetTempFile(nsILocalFile** aTempFile)
|
||||
{
|
||||
*aTempFile = mTempFile;
|
||||
NS_IF_ADDREF(*aTempFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DownloadState
|
||||
nsDownload::GetDownloadState()
|
||||
{
|
||||
|
|
|
@ -219,6 +219,8 @@ protected:
|
|||
nsresult GetDialogListener(nsIWebProgressListener** aInternalListener);
|
||||
nsresult SetDialog(nsIProgressDialog* aDialog);
|
||||
nsresult GetDialog(nsIProgressDialog** aDialog);
|
||||
nsresult SetTempFile(nsILocalFile* aTempFile);
|
||||
nsresult GetTempFile(nsILocalFile** aTempFile);
|
||||
nsresult SetCancelable(nsICancelable* aCancelable);
|
||||
nsresult SetTarget(nsIURI* aTarget);
|
||||
nsresult SetDisplayName(const PRUnichar* aDisplayName);
|
||||
|
@ -241,6 +243,7 @@ private:
|
|||
nsCOMPtr<nsICancelable> mCancelable;
|
||||
nsCOMPtr<nsIRequest> mRequest;
|
||||
nsCOMPtr<nsIProgressDialog> mDialog;
|
||||
nsCOMPtr<nsILocalFile> mTempFile;
|
||||
nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
|
||||
|
||||
DownloadState mDownloadState;
|
||||
|
|
Загрузка…
Ссылка в новой задаче