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

Is it possible to check to see if the file is *already* downloaded? #7272

Closed
jpheneger opened this issue Nov 18, 2022 · 3 comments
Closed

Is it possible to check to see if the file is *already* downloaded? #7272

jpheneger opened this issue Nov 18, 2022 · 3 comments

Comments

@jpheneger
Copy link

  • Electron-Builder Version: 23.6.0
  • Node Version: 16.7.1
  • Electron Version: 19.1.4
  • Electron Type (current, beta, nightly): current
  • Electron Updater Version: 5.3.0
  • Target: win/mac

When our app starts we register for multiple events from autoUpdater. We observe that when an update is available the 'update-available' event is triggered, and when the update has completed downloading the 'update-downloaded' event is triggered.

However, if the update was already downloaded, the 'update-available' event triggers before the 'update-downloaded' event triggers. This means that we prompt the user to download the update, and then IMMEDIATELY tell the user that it is downloaded.

We would be able to work around this issue if the cacheDir was exposed so that we could check to see if the file exists before prompting our users to download the update.

@mmaietta
Copy link
Collaborator

Not currently AFAICT. Happy to review a PR adding that update-* functionality in if you're willing to contribute!

@jpheneger
Copy link
Author

jpheneger commented Nov 23, 2022

I am happy to contribute, there are a couple of different ways this could be addressed:

  1. the most obvious way would be to expose the cacheDir variable so that I could check the directory myself.
    a. This requires that I add logic to check for the file AND account for all operating systems that I support (not ideal).
  2. Export a new variable from the updater that indicates whether or not the update was already downloaded.
    a. This removes the need for users to add logic, but does require exposing the inner workings a bit. Would require some documentation/education to be adopted widely.
  3. Add the variable "downloaded" to the UpdateInfo interface. When generating the "update-available" event, check to see if the file already exists in the cachDir. If it does, set "downloaded" to true.
    a. This has the benefit of exposing the downloaded state with the least amount of impact while also not exposing the inner workings of the library. It also means that any operating system specific logic is contained to the library.

I am strongly leaning towards option 3, thoughts?

@mmaietta
Copy link
Collaborator

AFAICT, the logic flow doesn't allow any of those approaches. update-available is purely checking server existence of an update. update-downloaded only occurs in the done(() => {}) callback with UpdateDownloadedEvent, but that's after it checks for the cache during the download flow. We can easily add a isCached to the update-downloaded event, but then the update-available event still exists without solving for your request.

Are you willing to adjust your UX flow? Instead of having two prompts/notifications, use something "Download & Install" as the only notification prompt?

I'm still trying to brainstorm how we could achieve the isCached eval

@mmaietta mmaietta closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants