зеркало из https://github.com/mozilla/pjs.git
Bug 311098: Remove .part files when cancelling downloads, ported from toolkit. r=biesi
This commit is contained in:
Родитель
8605163c99
Коммит
26bed9fabc
|
@ -495,6 +495,7 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
|
|||
targetFile->GetLeafName(displayName);
|
||||
}
|
||||
internalDownload->SetDisplayName(displayName.get());
|
||||
internalDownload->SetTempFile(aTempFile);
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> nameLiteral;
|
||||
gRDFService->GetLiteral(displayName.get(), getter_AddRefs(nameLiteral));
|
||||
|
@ -947,6 +948,16 @@ nsDownload::Cancel()
|
|||
return rv;
|
||||
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,
|
||||
// we have to notify it that we're cancelling
|
||||
nsCOMPtr<nsIObserver> observer = do_QueryInterface(GetDialog());
|
||||
|
@ -1433,3 +1444,10 @@ nsDownload::GetSpeed(double* aSpeed)
|
|||
*aSpeed = mSpeed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDownload::SetTempFile(nsILocalFile* aTempFile)
|
||||
{
|
||||
mTempFile = aTempFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ public:
|
|||
nsresult Cancel();
|
||||
nsresult Suspend();
|
||||
nsresult SetDisplayName(const PRUnichar* aDisplayName);
|
||||
nsresult SetTempFile(nsILocalFile* aTempFile);
|
||||
nsresult Resume();
|
||||
void DisplayDownloadFinishedAlert();
|
||||
|
||||
|
@ -173,6 +174,7 @@ private:
|
|||
nsCOMPtr<nsIRequest> mRequest;
|
||||
nsCOMPtr<nsIProgressDialog> mDialog;
|
||||
nsCOMPtr<nsIMIMEInfo> mMIMEInfo;
|
||||
nsCOMPtr<nsILocalFile> mTempFile;
|
||||
DownloadState mDownloadState;
|
||||
|
||||
PRInt32 mPercentComplete;
|
||||
|
|
Загрузка…
Ссылка в новой задаче