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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nervous-cherries-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix(nsis): Prevent partial updates from happening
Original file line number Diff line number Diff line change
Expand Up @@ -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.

ClearErrors
SetOutPath "$PLUGINSDIR\7z-out"
Nsis7z::Extract "${FILE}"
Pop $R0
SetOutPath $R0

# Retry counter
StrCpy $R1 0

LoopExtract7za:
IntOp $R1 $R1 + 1

CopyFiles /SILENT "$PLUGINSDIR\7z-out\*" $OUTDIR
IfErrors 0 DoneExtract7za

${if} $R1 > 1
DetailPrint `Can't modify "${PRODUCT_NAME}"'s files.`
${if} $R1 < 5
# Try copying a few times before giving up
Goto LoopExtract7za
${else}
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(appCannotBeClosed)" /SD IDCANCEL IDRETRY RetryExtract7za
${endIf}

# CopyFiles will remove all overwritten files when it encounters an
# issue and make app non-launchable. Extract over from the archive
# ignoring the failures so at least we will partially update and the
# app would start.
Nsis7z::Extract "${FILE}"
Quit
${else}
Goto LoopExtract7za
${endIf}

RetryExtract7za:
Sleep 1000
Goto LoopExtract7za

DoneExtract7za:
!macroend