Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Windows: an update whose old uninstaller fails installs over it instead of stopping with "Failed to uninstall old application files" (#126)

christianmatc5c2006b34c0
diff --git a/app/build/installer.nsh b/app/build/installer.nsh
new file mode 100644
index 00000000..11e42d9c
--- /dev/null
+++ b/app/build/installer.nsh
@@ -0,0 +1,26 @@
+; Windows installer additions (electron-builder's nsis.include).
+;
+; An update runs the old version's uninstaller first. When that crashed (#126: 0xC0000374, heap corruption, in the old
+; uninstaller itself), electron-builder's installer stopped with "Failed to uninstall old application files" and the
+; person had to download the installer by hand. Every file this version needs is written over the old ones next, and
+; the app data is never touched (deleteAppDataOnUninstall is off), so a failed old uninstaller is noted and the install
+; carries on. Both macros: a per-machine and a per-user install are checked separately.
+!include LogicLib.nsh
+
+!macro customUnInstallCheck
+ ${If} ${Errors}
+ DetailPrint `The old version's uninstaller did not start; installing over it.`
+ ${ElseIf} $R0 != 0
+ DetailPrint `The old version's uninstaller failed (code $R0); installing over it.`
+ ${EndIf}
+ ClearErrors
+!macroend
+
+!macro customUnInstallCheckCurrentUser
+ ${If} ${Errors}
+ DetailPrint `The old version's uninstaller did not start; installing over it.`
+ ${ElseIf} $R0 != 0
+ DetailPrint `The old version's uninstaller failed (code $R0); installing over it.`
+ ${EndIf}
+ ClearErrors
+!macroend
diff --git a/app/electron-builder.yml b/app/electron-builder.yml
index 38b89f29..9ca2b597 100644
--- a/app/electron-builder.yml
+++ b/app/electron-builder.yml
@@ -113,6 +113,8 @@ win:
icon: build/icon.png
nsis:
oneClick: true
+ # carries on when an update's old uninstaller fails (#126)
+ include: build/installer.nsh
perMachine: false
# never true: uninstalling would delete every meeting, transcript and recording with the models
deleteAppDataOnUninstall: false
diff --git a/app/test/windowsUninstall.test.ts b/app/test/windowsUninstall.test.ts
new file mode 100644
index 00000000..18d39ada
--- /dev/null
+++ b/app/test/windowsUninstall.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { join } from 'node:path'
+
+// #126: an update runs the old version's uninstaller first. When it crashed (0xC0000374), electron-builder's installer
+// stopped with "Failed to uninstall old application files" and the person had to download the installer by hand.
+// The new installer writes every file it needs over the old ones, so it notes the failure and carries on.
+const builder = readFileSync(join(__dirname, '../electron-builder.yml'), 'utf8').replaceAll('\r\n', '\n')
+const nsis = builder.slice(builder.indexOf('\nnsis:'), builder.indexOf('\nlinux:'))
+const script = () => readFileSync(join(__dirname, '../build/installer.nsh'), 'utf8')
+
+describe('a Windows update whose old uninstaller fails (#126)', () => {
+ it('includes Yogurt\'s installer script', () => {
+ expect(nsis).toMatch(/\n include: build\/installer\.nsh\n/)
+ })
+ it('handles the old uninstaller\'s result itself, for per-user installs too, and never quits over it', () => {
+ const s = script()
+ expect(s).toMatch(/!macro customUnInstallCheck\b[\s\S]*?!macroend/)
+ expect(s).toMatch(/!macro customUnInstallCheckCurrentUser\b[\s\S]*?!macroend/)
+ for (const name of ['customUnInstallCheck', 'customUnInstallCheckCurrentUser']) {
+ const body = s.match(new RegExp(`!macro ${name}\\b([\\s\\S]*?)!macroend`))![1]
+ expect(body).toContain('DetailPrint')
+ expect(body).not.toMatch(/\bQuit\b|\bAbort\b|MessageBox/)
+ }
+ })
+})