document @mozilla.org/download;1

don't delete incomplete files when the download is cancelled/aborts
tell the download impl about the location of the temp file, if it is interested
244448 r=bzbarsky sr=darin
This commit is contained in:
cbiesinger%web.de 2004-05-26 15:07:52 +00:00
Родитель 577773ee38
Коммит 2e0a3492fe
2 изменённых файлов: 32 добавлений и 1 удалений

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

@ -141,7 +141,29 @@ interface nsIDownload : nsITransfer {
};
%{C++
/**
* A component with this contract ID will be created each time a download is
* started, and Init will be called on it and an observer will be set.
*
* Notifications of the download progress will happen via
* nsIWebProgressListener.
*
* If nsIObserver is implemented, the component may get a notification with
* topic "temp-file" and an nsILocalFile instance as subject, which indicates
* the location of a temporary file; i.e. a file in which the received data will
* be stored, but which is not equal to the target file.
*
* INTERFACES THAT NEED TO BE IMPLEMENTED:
* nsISupports
* nsITransfer
* nsIDownload
* nsIWebProgressListener
*
* INTERFACES THAT MAY BE IMPLEMENTED:
* nsIObserver
*/
#define NS_DOWNLOAD_CONTRACTID "@mozilla.org/download;1"
// {E3FA9D0A-1DD1-11B2-BDEF-8C720B597445}
#define NS_DOWNLOAD_CID \
{ 0xe3fa9d0a, 0x1dd1, 0x11b2, { 0xbd, 0xef, 0x8c, 0x72, 0x0b, 0x59, 0x74, 0x45 } }

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

@ -1845,6 +1845,11 @@ nsresult nsExternalAppHandler::InitializeDownload(nsIDownload* aDownload)
rv = aDownload->SetObserver(this);
// Tell the listener about the location of the target file
nsCOMPtr<nsIObserver> obs(do_QueryInterface(aDownload));
if (obs)
obs->Observe(mTempFile, "temp-file", nsnull);
return rv;
}
@ -2169,7 +2174,11 @@ NS_IMETHODIMP nsExternalAppHandler::Cancel()
}
// clean up after ourselves and delete the temp file...
if (mTempFile)
// but only if we got asked to open the file. when saving,
// we leave the file there - the partial file might be useful
nsMIMEInfoHandleAction action = nsIMIMEInfo::saveToDisk;
mMimeInfo->GetPreferredAction(&action);
if (mTempFile && action != nsIMIMEInfo::saveToDisk)
{
mTempFile->Remove(PR_TRUE);
mTempFile = nsnull;