Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort download #1150

Closed
sante85 opened this issue Jan 20, 2017 · 20 comments

Comments

Projects
None yet
6 participants
@sante85
Copy link

commented Jan 20, 2017

  • Version:
    last tag
  • Target:
    all

Make it possible abort download?

@develar

This comment has been minimized.

Copy link
Member

commented Jan 20, 2017

What do you mean?

@sante85

This comment has been minimized.

Copy link
Author

commented Jan 20, 2017

when autoUpdater download release file, and another event is emitted, I want programmatically abort (stop) download in progress and delete file in temp directory.

  1. delete file in temp directory even next release has been successfully installed.

Thanks

@sante85

This comment has been minimized.

Copy link
Author

commented Jan 23, 2017

Hi developer,
the problem is clear?

Thanks

@develar

This comment has been minimized.

Copy link
Member

commented Jan 23, 2017

You can abort download —

  1. checkForUpdates returns Promise of UpdateCheckResult.
  2. UpdateCheckResult has property downloadPromise.
  3. We use special configured Bluebird — you can call 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).

@sante85

This comment has been minimized.

Copy link
Author

commented Jan 23, 2017

I use generic provider on windows OS

@sante85

This comment has been minimized.

Copy link
Author

commented Jan 23, 2017

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.

@sante85

This comment has been minimized.

Copy link
Author

commented Jan 23, 2017

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.

@sante85

This comment has been minimized.

Copy link
Author

commented Feb 6, 2017

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

@sante85

This comment has been minimized.

Copy link
Author

commented Feb 16, 2017

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

@Ruj89

This comment has been minimized.

Copy link

commented Feb 16, 2017

up

@develar develar changed the title Make it possible abort download? Abort download Feb 17, 2017

develar added a commit to develar/electron-builder that referenced this issue Feb 17, 2017

@develar develar closed this in 91613a9 Feb 17, 2017

@develar

This comment has been minimized.

Copy link
Member

commented Feb 17, 2017

UpdateCheckResult now has cancellationToken property — call cancellationToken.cancel()

@develar

This comment has been minimized.

Copy link
Member

commented Feb 17, 2017

Docs will be updated later.

@sante85

This comment has been minimized.

Copy link
Author

commented Mar 3, 2017

hi developer,
how to pass cancellationToken to updater? he write docs please?

@New-Key

This comment has been minimized.

Copy link

commented Sep 3, 2017

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 ?

@develar

This comment has been minimized.

Copy link
Member

commented Sep 3, 2017

@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()
@develar

This comment has been minimized.

Copy link
Member

commented Sep 3, 2017

@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.

@genesy

This comment has been minimized.

Copy link

commented Jun 30, 2018

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?

@jason-zuo

This comment has been minimized.

Copy link

commented Jul 10, 2018

@genesy hi ,i face the same problem ,can you fixed it?

@genesy

This comment has been minimized.

Copy link

commented Jul 10, 2018

@jason-zuo nope just left it as is. might be meant that way

@develar

This comment has been minimized.

Copy link
Member

commented Nov 8, 2018

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).

develar added a commit to develar/electron-builder that referenced this issue Nov 8, 2018

develar added a commit to develar/electron-builder that referenced this issue Nov 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.