Bug 311098: Remove .part files when cancelling downloads, ported from toolkit. r=biesi

This commit is contained in:
ajschult%verizon.net 2006-08-05 23:57:31 +00:00
Родитель 8605163c99
Коммит 26bed9fabc
2 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -495,6 +495,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
targetFile->GetLeafName(displayName); targetFile->GetLeafName(displayName);
} }
internalDownload->SetDisplayName(displayName.get()); internalDownload->SetDisplayName(displayName.get());
internalDownload->SetTempFile(aTempFile);
nsCOMPtr<nsIRDFLiteral> nameLiteral; nsCOMPtr<nsIRDFLiteral> nameLiteral;
gRDFService->GetLiteral(displayName.get(), getter_AddRefs(nameLiteral)); gRDFService->GetLiteral(displayName.get(), getter_AddRefs(nameLiteral));
@ -947,6 +948,16 @@ nsDownload::Cancel()
return rv; return rv;
mDownloadManager->DownloadEnded(path, nsnull); mDownloadManager->DownloadEnded(path, 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
if (mTempFile) {
PRBool exists;
mTempFile->Exists(&exists);
if (exists)
mTempFile->Remove(PR_FALSE);
}
// if there's a progress dialog open for the item, // if there's a progress dialog open for the item,
// we have to notify it that we're cancelling // we have to notify it that we're cancelling
nsCOMPtr<nsIObserver> observer = do_QueryInterface(GetDialog()); nsCOMPtr<nsIObserver> observer = do_QueryInterface(GetDialog());
@ -1433,3 +1444,10 @@ nsDownload::GetSpeed(double* aSpeed)
*aSpeed = mSpeed; *aSpeed = mSpeed;
return NS_OK; return NS_OK;
} }
nsresult
nsDownload::SetTempFile(nsILocalFile* aTempFile)
{
mTempFile = aTempFile;
return NS_OK;
}

Просмотреть файл

@ -123,6 +123,7 @@ public:
nsresult Cancel(); nsresult Cancel();
nsresult Suspend(); nsresult Suspend();
nsresult SetDisplayName(const PRUnichar* aDisplayName); nsresult SetDisplayName(const PRUnichar* aDisplayName);
nsresult SetTempFile(nsILocalFile* aTempFile);
nsresult Resume(); nsresult Resume();
void DisplayDownloadFinishedAlert(); void DisplayDownloadFinishedAlert();
@ -173,6 +174,7 @@ private:
nsCOMPtr<nsIRequest> mRequest; nsCOMPtr<nsIRequest> mRequest;
nsCOMPtr<nsIProgressDialog> mDialog; nsCOMPtr<nsIProgressDialog> mDialog;
nsCOMPtr<nsIMIMEInfo> mMIMEInfo; nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
nsCOMPtr<nsILocalFile> mTempFile;
DownloadState mDownloadState; DownloadState mDownloadState;
PRInt32 mPercentComplete; PRInt32 mPercentComplete;