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

fix(NSIS): prevent partial overwrites #6547

Conversation

indutny-signal
Copy link
Contributor

@indutny-signal indutny-signal commented Jan 12, 2022

Nsis7z::Extract ignores the errors when copying the files and thus can
leave us with the app that has old asar and bindings, but new assets. In
addition to that, the app will firmly believe that it is still running
an old version and would attempt to repeatedly auto-update until fixed,
leading to excessive bandwidth use and very unhappy customers.

This change extracts the contents of 7z archive into a separate
directory before attempting to copy them with CopyFiles function that
(unlike Nsis7z::Extract) does detect and report failures. To make our
lives easier the CopyFiles will also erase all files on a failure so
after retrying a few times we will ultimately have to fallback to old 7z
extraction directly into output folder.

Testing

The easiest way to trigger the failure is to:

  1. Go to the application folder
  2. Copy exe file to tmp.exe
  3. Start tmp.exe (thus locking the asar, bindings, and dlls)
  4. Try to install over with freshly built installer

`Nsis7z::Extract` ignores the errors when copying the files and thus can
leave us with the app that has old asar and bindings, but new assets. In
addition to that, the app will firmly believe that it is still running
an old version and would attempt to repeatedly auto-update until fixed,
leading to excessive bandwidth use and very unhappy customers.

This change extracts the contents of 7z archive into a separate
directory before attempting to copy them with `CopyFiles` function that
(unlike `Nsis7z::Extract`) does detect and report failures. To make our
lives easier the `CopyFiles` will also erase all files on a failure so
after retrying a few times we will ultimately have to fallback to old 7z
extraction directly into output folder.
@changeset-bot
Copy link

changeset-bot bot commented Jan 12, 2022

🦋 Changeset detected

Latest commit: d7c4edd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Patch
dmg-builder Patch
electron-builder-squirrel-windows Patch
electron-builder Patch
electron-forge-maker-appimage Patch
electron-forge-maker-nsis-web Patch
electron-forge-maker-nsis Patch
electron-forge-maker-snap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Jan 12, 2022

✔️ Deploy Preview for car-park-attendant-cleat-11576 ready!

🔨 Explore the source changes: d7c4edd

🔍 Inspect the deploy log: https://app.netlify.com/sites/car-park-attendant-cleat-11576/deploys/61df2fe2760c6b0008426cfd

😎 Browse the preview: https://deploy-preview-6547--car-park-attendant-cleat-11576.netlify.app

@@ -90,5 +90,45 @@
!macroend

!macro extractUsing7za FILE
Nsis7z::Extract "${FILE}"
Push $OUTDIR
CreateDirectory "$PLUGINSDIR\7z-out"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: NSIS promises that $PLUGINSDIR is a temporary folder that is removed after the installation.

@mmaietta mmaietta merged commit bea51d6 into electron-userland:master Jan 12, 2022
@indutny-signal indutny-signal deleted the fix/partial-updates-with-nsis branch January 12, 2022 23:05
@indutny-signal
Copy link
Contributor Author

Yay. Thanks for merging it so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants