Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(installer): der alte Frontend-Stapel wird beim Update weggeraeumt

purple17c8701bdef8
diff --git a/src-tauri/windows/installer-hooks.nsh b/src-tauri/windows/installer-hooks.nsh
index def74a68..35753c6e 100644
--- a/src-tauri/windows/installer-hooks.nsh
+++ b/src-tauri/windows/installer-hooks.nsh
@@ -153,9 +153,44 @@
Delete "$INSTDIR\llama-server.exe.old"
!macroend
+; The old frontend bundle piles up forever, and nothing ever swept it.
+;
+; Measured on the Windows box on 2026-09-04, in an install folder that has
+; taken every update since April:
+;
+; _up_\dist\assets 1170 files 131,9 MB
+; of which from the build installed that morning 266
+; oldest file 2026-04-15
+;
+; So roughly 900 dead files and 110 MB that every updating user carries around.
+; The cause is the pair of habits meeting: Vite puts a content hash in every
+; chunk name, so a new build never overwrites the old chunk, it lands beside
+; it, and NSIS only ever COPIES what the package brings, it never removes what
+; the previous version left. Neither half is wrong on its own. Together they
+; grow the install without limit.
+;
+; The whole folder belongs to the installer. There is nothing of the user's in
+; it: chats, settings, models and outputs live under the app data folders, and
+; the bundle identifier that names them never changes. So it can go wholesale
+; and be laid down fresh.
+;
+; The check on index.html is not for us, it is for a wrong $INSTDIR. A
+; recursive delete is the one instruction in this file that cannot be taken
+; back, and it should only ever run where our own frontend really lies.
+;
+; A file that is still locked is skipped by RMDir without an error, which is
+; the right outcome: one leftover chunk is harmless, and the next install
+; sweeps it.
+!macro LU_SWEEP_OLD_FRONTEND
+ ${If} ${FileExists} "$INSTDIR\_up_\dist\index.html"
+ RMDir /r "$INSTDIR\_up_\dist"
+ ${EndIf}
+!macroend
+
!macro NSIS_HOOK_PREINSTALL
!insertmacro LU_FREE_SIDECAR "lu-llama-server.exe"
!insertmacro LU_SWEEP_OLD_SIDECAR
+ !insertmacro LU_SWEEP_OLD_FRONTEND
!if "${PRODUCTNAME}" != "Locally Uncensored"
!insertmacro LU_REMOVE_OLD_NSIS HKCU
diff --git a/src/lib/__tests__/installer-frees-sidecar.test.ts b/src/lib/__tests__/installer-frees-sidecar.test.ts
index b1a99a30..b47dfeac 100644
--- a/src/lib/__tests__/installer-frees-sidecar.test.ts
+++ b/src/lib/__tests__/installer-frees-sidecar.test.ts
@@ -39,10 +39,13 @@ const conf = JSON.parse(read('src-tauri/tauri.conf.json')) as {
}
// Only the unlock macro. The dormant product-rename macro below it kills the
-// app itself and is a different question.
+// app itself and is a different question, and so is the frontend sweep that
+// now sits between them: this slice used to run to NSIS_HOOK_PREINSTALL and
+// swallowed everything in between, so the cases below would have started
+// making claims about code they were never written for.
const unlock = hooks.slice(
hooks.indexOf('!macro LU_FREE_SIDECAR'),
- hooks.indexOf('!macro NSIS_HOOK_PREINSTALL'),
+ hooks.indexOf('!macro LU_SWEEP_OLD_FRONTEND'),
)
describe('the installer frees the bundled engine', () => {
@@ -149,3 +152,60 @@ describe('an update from before the rename does not leave the old engine behind'
}
})
})
+
+/**
+ * Was der Installer hinlegt, muss er auch wieder wegnehmen koennen.
+ *
+ * Gemessen am 04.09.2026 auf der Windows-Box, in einem Ordner, der seit April
+ * jede Aktualisierung mitgenommen hat:
+ *
+ * _up_\dist\assets 1170 Dateien 131,9 MB
+ * davon aus dem an dem Morgen installierten Build 266
+ * aelteste Datei 15.04.2026
+ *
+ * Rund 900 tote Dateien und gut 110 MB, die jeder Nutzer mitschleppt. Der
+ * Grund sind zwei Gewohnheiten, die einzeln richtig sind: Vite haengt an jeden
+ * Brocken einen Hash, ein neuer Build ueberschreibt den alten also nie sondern
+ * legt sich daneben, und NSIS kopiert nur, es raeumt nie weg.
+ */
+describe('der Installer laesst den alten Frontend-Stapel nicht liegen', () => {
+ const preinstall = hooks.slice(hooks.indexOf('!macro NSIS_HOOK_PREINSTALL'))
+ const sweep = hooks.slice(
+ hooks.indexOf('!macro LU_SWEEP_OLD_FRONTEND'),
+ hooks.indexOf('!macro NSIS_HOOK_PREINSTALL'),
+ )
+
+ it('raeumt vor jedem Kopieren auf, in jedem Build', () => {
+ expect(preinstall).toContain('!insertmacro LU_SWEEP_OLD_FRONTEND')
+ // Vor dem Umbenennungsschalter, sonst waere es wieder toter Code, genau
+ // wie die Entsperrung es einmal war.
+ expect(preinstall.indexOf('!insertmacro LU_SWEEP_OLD_FRONTEND'))
+ .toBeLessThan(preinstall.indexOf('!if "${PRODUCTNAME}"'))
+ })
+
+ it('nimmt den ganzen Ordner, nicht einzelne Dateien', () => {
+ // Eine Liste von Namen waere sinnlos: die Namen sind Hashes und heissen bei
+ // jedem Build anders. Genau daran ist das Aufraeumen bisher gescheitert.
+ expect(sweep).toContain('RMDir /r "$INSTDIR\\_up_\\dist"')
+ })
+
+ it('nur dort, wo unser Frontend wirklich liegt', () => {
+ // Das rekursive Loeschen ist die einzige Anweisung in dieser Datei, die
+ // sich nicht zuruecknehmen laesst. Sie darf bei einem falschen $INSTDIR
+ // nicht losgehen.
+ expect(sweep).toContain('${FileExists} "$INSTDIR\\_up_\\dist\\index.html"')
+ expect(sweep.indexOf('FileExists')).toBeLessThan(sweep.indexOf('RMDir'))
+ })
+
+ it('faesst nichts an, worin Nutzerdaten liegen koennten', () => {
+ // Negativkontrolle. Chats, Einstellungen, Modelle und Ergebnisse liegen
+ // unter den App-Data-Ordnern, nie im Installationsordner. Ein RMDir auf
+ // $APPDATA oder auf $INSTDIR selbst waere ein Datenverlust, kein Aufraeumen.
+ expect(sweep).not.toContain('RMDir /r "$INSTDIR"')
+ expect(sweep).not.toContain('$APPDATA')
+ expect(sweep).not.toContain('$LOCALAPPDATA')
+ expect(sweep).not.toContain('$DOCUMENTS')
+ // Und der Ordner mit den Modellen der Engine schon gar nicht.
+ expect(sweep).not.toContain('resources')
+ })
+})