Make it possible abort download?
What do you mean?
when autoUpdater download release file, and another event is emitted, I want programmatically abort (stop) download in progress and delete file in temp directory.
Thanks
Hi developer,
the problem is clear?
Thanks
You can abort download —
downloadPromise.downloadPromise.cancel()But — isCancelled is not checked by electronHttpExecutor.ts or nodeHttpExecutor.ts. To be fixed.
delete file in temp directory even next release has been successfully installed.
It is a different issue. To investigate (currently we suppose that OS will delete temp files).
I use generic provider on windows OS
we automatically delete temp file, because if download fail, on reopen app, it try dowload update. Repeating this step many times and create problem on disk full temp directory.
The problem is that while downloading the update, I wish I could stop at any time. Then if it is blocked or fails for other reasons, the temporary file should be deleted.
when autoUpdater download release file, and another event is emitted, I want programmatically abort (stop) download in progress and delete file in temp directory.
delete file in temp directory even next release has been successfully installed.
Thanks
when autoUpdater download release file, and another event is emitted, I want programmatically abort (stop) download in progress and delete file in temp directory.
thanks
up
UpdateCheckResult now has cancellationToken property — call cancellationToken.cancel()
Docs will be updated later.
hi developer,
how to pass cancellationToken to updater? he write docs please?
How is the implementation to abort the Download? I'm not clear in this aspect, checkForUpdates return a promise which I see on the JSON, but the implementations, to stop by user's demand, when autoDownload is false ?
@New-Key
Set autoDownload to false and then you can call autoUdater.downloadUpdate directly.
import { CancellationToken } from "electron-updater"
const cancellationToken = new CancellationToken()
autoUdater.downloadUpdate(cancellationToken)
// stop download
cancellationToken.cancel()
@New-Key I don't want expose electron-builder-http so, in the next version CancellationToken will be available from electron-updater. I will add example to docs.
Am I doing this right ?
autoUpdater.checkForUpdates().then((downloadPromise) => {
cancellationToken = downloadPromise.cancellationToken;
});
someEvent.then(() => { cancellationToken.cancel() })
when i trigger cancellationToken.cancel() i get an error Error: Cancelled why is it an error if i'm purposely doing it?
@genesy hi ,i face the same problem ,can you fixed it?
@jason-zuo nope just left it as is. might be meant that way
electron-updater 3.2.2 will not dispatch error event for CancellationError, but returned promise still will be rejected with CancellationError because otherwise not easy for you to handle this properly (either then or catch handlers must be called for Promise, so, it is logical to call catch).
Most helpful comment
@New-Key
Set
autoDownloadtofalseand then you can callautoUdater.downloadUpdatedirectly.