Skip to content

Commit fcef6d5

Browse files
committed
fix(windows): NSIS install log integrity and step mirroring
Write %TEMP%\HyperlinksSpaceUpdater.log in three FileWrite calls (timestamp prefix, body, CRLF) instead of one long literal, so NSIS variable parsing does not corrupt lines when paths use $INSTDIR\... alongside $R* and colons in the time stamp. Use dedicated HspLogHandle / un.HspLogHandle instead of $R9 for the log file, avoiding overlap with nsExec::ExecToLog Pop $R9 in installSection.nsh. Log junction removal with ${INSTDIR}\current in the mirrored message, matching the recommended ${VAR}\path form. Introduce HspInstallDetailPrint and use it for each install milestone so DetailPrint lines are also appended to the temp log when the MUI Installing list stays empty. Made-with: Cursor
1 parent c25267f commit fcef6d5

2 files changed

Lines changed: 39 additions & 28 deletions

File tree

app/windows/installSection.nsh

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Fork of app-builder-lib/templates/nsis/installSection.nsh (electron-builder).
2-
; Only change: show installation details (SetDetailsPrint both) instead of none, plus
3-
; versioned install layout under $INSTDIR\versions\<VERSION> and current junction.
2+
; Debug: if the Installing list stays empty, open %TEMP%\HyperlinksSpaceUpdater.log — HspInstallDetailPrint
3+
; mirrors each milestone there (proves NSIS ran the line even when the UI list does not repaint).
44
;
55
; Source lives here (not app/build/). package.json sets directories.buildResources to
66
; "windows" so NSIS resolves this file before templates/nsis/installSection.nsh.
@@ -13,11 +13,8 @@ InitPluginsDir
1313

1414
; Do not wrap DetailPrint in ${IfNot} ${Silent}: on some builds ${Silent} evaluates in a way that
1515
; skips all section DetailPrint lines while the InstFiles SHOW hook still runs (only one line visible).
16-
; listonly: send DetailPrint into the white list (MUI2 often leaves the list empty with "both" alone).
17-
SetDetailsPrint listonly
18-
SetDetailsView show
1916
; 7-Zip extraction does not stream filenames into the NSIS list (unlike File commands).
20-
DetailPrint "Step 1/10 - Preparing ${PRODUCT_NAME} ${VERSION}..."
17+
!insertmacro HspInstallDetailPrint "Step 1/10 - Preparing ${PRODUCT_NAME} ${VERSION}..."
2118

2219
; Installed layout: $INSTDIR\versions\<VERSION>\* and $INSTDIR\current → junction to that folder.
2320
; For upgrade checks, prefer an existing versioned or legacy flat exe.
@@ -32,7 +29,7 @@ ${EndIf}
3229
# must be called before uninstallOldVersion
3330
!insertmacro setLinkVars
3431

35-
DetailPrint "Step 2/10 - Checking that ${PRODUCT_NAME} is not running..."
32+
!insertmacro HspInstallDetailPrint "Step 2/10 - Checking that ${PRODUCT_NAME} is not running..."
3633

3734
!ifdef ONE_CLICK
3835
!ifdef HEADER_ICO
@@ -72,7 +69,7 @@ ${if} $isTryToKeepShortcuts == "true"
7269
${endIf}
7370
${EndIf}
7471

75-
DetailPrint "Step 3/10 - Checking for a previous installation and uninstalling the old build if needed..."
72+
!insertmacro HspInstallDetailPrint "Step 3/10 - Checking for a previous installation and uninstalling the old build if needed..."
7673
!insertmacro uninstallOldVersion SHELL_CONTEXT
7774
!insertmacro handleUninstallResult SHELL_CONTEXT
7875

@@ -81,35 +78,32 @@ ${if} $installMode == "all"
8178
!insertmacro handleUninstallResult HKEY_CURRENT_USER
8279
${endIf}
8380

84-
DetailPrint "Step 4/10 - Creating versioned install folder versions\${VERSION}..."
81+
!insertmacro HspInstallDetailPrint "Step 4/10 - Creating versioned install folder versions\${VERSION}..."
8582
CreateDirectory "$INSTDIR\versions"
8683
SetOutPath "$INSTDIR\versions\${VERSION}"
8784

8885
!ifdef UNINSTALLER_ICON
8986
File /oname=uninstallerIcon.ico "${UNINSTALLER_ICON}"
9087
!endif
9188

92-
DetailPrint "Step 5/10 - Extracting application package with 7-Zip (longest step; file names are not listed)..."
93-
; File extraction toggles status_update around compressed reads; keep listbox as the log target.
94-
SetDetailsPrint listonly
95-
SetDetailsView show
89+
!insertmacro HspInstallDetailPrint "Step 5/10 - Extracting application package with 7-Zip (longest step; file names are not listed)..."
9690
!insertmacro installApplicationFiles
97-
DetailPrint "Step 6/10 - Extraction finished."
98-
DetailPrint "Step 7/10 - Pointing 'current' at versions\${VERSION} (directory junction)..."
91+
!insertmacro HspInstallDetailPrint "Step 6/10 - Extraction finished."
92+
!insertmacro HspInstallDetailPrint "Step 7/10 - Pointing 'current' at versions\${VERSION} (directory junction)..."
9993
; Directory junction so shortcuts and the updater always use …\current\<exe>
10094
IfFileExists "$INSTDIR\current" hspRemoveOldCurrent hspMklinkCurrent
10195
hspRemoveOldCurrent:
102-
DetailPrint " (removing existing junction or folder: $INSTDIR\current)"
96+
!insertmacro HspInstallDetailPrint " (removing existing junction or folder: ${INSTDIR}\current)"
10397
nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c rmdir "$INSTDIR\current"'
10498
Pop $R9
10599
hspMklinkCurrent:
106-
DetailPrint " (creating junction: current -> versions\${VERSION})"
100+
!insertmacro HspInstallDetailPrint " (creating junction: current -> versions\${VERSION})"
107101
nsExec::ExecToLog '"$SYSDIR\cmd.exe" /c mklink /J "$INSTDIR\current" "$INSTDIR\versions\${VERSION}"'
108102
Pop $R9
109103
StrCpy $appExe "$INSTDIR\current\${APP_EXECUTABLE_FILENAME}"
110-
DetailPrint "Step 8/10 - Writing install location and Add/Remove Programs registry entries..."
104+
!insertmacro HspInstallDetailPrint "Step 8/10 - Writing install location and Add/Remove Programs registry entries..."
111105
!insertmacro registryAddInstallInfo
112-
DetailPrint "Step 9/10 - Creating Start Menu and desktop shortcuts..."
106+
!insertmacro HspInstallDetailPrint "Step 9/10 - Creating Start Menu and desktop shortcuts..."
113107
!insertmacro addStartMenuLink $keepShortcuts
114108
!insertmacro addDesktopLink $keepShortcuts
115109

@@ -120,13 +114,12 @@ ${else}
120114
${endIf}
121115

122116
!ifmacrodef registerFileAssociations
123-
DetailPrint "Registering file associations..."
117+
!insertmacro HspInstallDetailPrint "Registering file associations..."
124118
!insertmacro registerFileAssociations
125119
!endif
126120

127121
!ifmacrodef customInstall
128-
DetailPrint "Step 10/10 - Running final install hooks..."
129-
; So customInstall's DetailPrint targets the listbox.
122+
!insertmacro HspInstallDetailPrint "Step 10/10 - Running final install hooks..."
130123
SetDetailsPrint listonly
131124
SetDetailsView show
132125
!insertmacro customInstall

app/windows/installer-hooks.nsi

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,40 @@ Function HspInstFilesShow
4848
FunctionEnd
4949

5050
Var HspLogFile
51+
Var HspLogHandle
5152
Function HspEnsureUpdaterLogPath
5253
StrCmp $HspLogFile "" hspSetLogPath hspLogPathDone
5354
hspSetLogPath:
5455
StrCpy $HspLogFile "$TEMP\HyperlinksSpaceUpdater.log"
5556
hspLogPathDone:
5657
FunctionEnd
5758

59+
; Append in three writes: avoids one huge FileWrite string mixing $R0-$R6, colons, and runtime $VAR\path
60+
; (NSIS recommends ${INSTDIR}\file when a path follows a variable; mixed literals have misparsed before).
5861
!macro HspAppendUpdaterLog TEXT
5962
Call HspEnsureUpdaterLogPath
6063
${GetTime} "" "L" $R0 $R1 $R2 $R3 $R4 $R5 $R6
6164
; FileFunc GetTime (local): $R0=day $R1=month $R2=year $R3=weekday name (unused) $R4:$R5:$R6=time
62-
FileOpen $R9 "$HspLogFile" a
63-
FileWrite $R9 "[$R2-$R1-$R0 $R4:$R5:$R6] ${TEXT}$\r$\n"
64-
FileClose $R9
65+
StrCpy $R7 "[$R2-$R1-$R0 $R4:$R5:$R6] "
66+
FileOpen $HspLogHandle "$HspLogFile" a
67+
FileWrite $HspLogHandle $R7
68+
FileWrite $HspLogHandle "${TEXT}"
69+
FileWrite $HspLogHandle "$\r$\n"
70+
FileClose $HspLogHandle
71+
!macroend
72+
73+
; Re-assert list mode + mirror to HyperlinksSpaceUpdater.log (debug when MUI listbox stays empty).
74+
!macro HspInstallDetailPrint MSG
75+
SetDetailsPrint listonly
76+
SetDetailsView show
77+
DetailPrint "${MSG}"
78+
!insertmacro HspAppendUpdaterLog "${MSG}"
6579
!macroend
6680
!endif
6781

6882
!ifdef BUILD_UNINSTALLER
6983
Var un.HspLogFile
84+
Var un.HspLogHandle
7085
Function un.HspEnsureUpdaterLogPath
7186
StrCmp $un.HspLogFile "" hspUnSetLogPath hspUnLogPathDone
7287
hspUnSetLogPath:
@@ -77,9 +92,12 @@ FunctionEnd
7792
!macro HspAppendUpdaterLog TEXT
7893
Call un.HspEnsureUpdaterLogPath
7994
${GetTime} "" "L" $R0 $R1 $R2 $R3 $R4 $R5 $R6
80-
FileOpen $R9 "$un.HspLogFile" a
81-
FileWrite $R9 "[$R2-$R1-$R0 $R4:$R5:$R6] ${TEXT}$\r$\n"
82-
FileClose $R9
95+
StrCpy $R7 "[$R2-$R1-$R0 $R4:$R5:$R6] "
96+
FileOpen $un.HspLogHandle "$un.HspLogFile" a
97+
FileWrite $un.HspLogHandle $R7
98+
FileWrite $un.HspLogHandle "${TEXT}"
99+
FileWrite $un.HspLogHandle "$\r$\n"
100+
FileClose $un.HspLogHandle
83101
!macroend
84102
!endif
85103

0 commit comments

Comments
 (0)