From 240c67219866dd751b23c7c9628fc157653cb9e0 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 26 Apr 2026 08:50:44 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Update-UI=20zeigt=20alte=20Version=20/?= =?UTF-8?q?=20schlie=C3=9Ft=20sofort=20ab=20(Race=20Condition)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: state-Datei vom letzten Update zeigte noch 'done'. pollUpdate() las das direkt nach runUpdate() als "Update fertig" — bevor der neue Prozess überhaupt startete. displayCurrent war dann noch die alte Version. Fix: - runUpdate() setzt state='starting' und löscht rc VOR dem Shell-Aufruf - runUpdate() setzt rc=null, lowState='starting', postActionsDone=false zurück - refreshLowLevelState(): Kommentar klärt dass 'starting' als running gilt Co-Authored-By: Claude Sonnet 4.6 --- app/Livewire/Ui/System/UpdateCard.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/Livewire/Ui/System/UpdateCard.php b/app/Livewire/Ui/System/UpdateCard.php index c88e750..989e8d8 100644 --- a/app/Livewire/Ui/System/UpdateCard.php +++ b/app/Livewire/Ui/System/UpdateCard.php @@ -66,20 +66,28 @@ class UpdateCard extends Component public function runUpdate(): void { - // evtl. alte Einträge aufräumen + // State-Dateien VOR dem Start zurücksetzen — verhindert dass pollUpdate() + // das "done" vom letzten Update liest und sofort als "fertig" wertet. + @mkdir('/var/lib/mailwolt/update', 0755, true); + @file_put_contents('/var/lib/mailwolt/update/state', 'starting'); + @unlink('/var/lib/mailwolt/update/rc'); + Cache::forget('mailwolt.update_available'); Cache::put($this->cacheStartedAtKey, time(), now()->addHour()); $this->dispatch('openModal', component: 'ui.system.modal.update-modal'); @shell_exec('nohup sudo -n /usr/local/sbin/mailwolt-update >/dev/null 2>&1 &'); // Sofort ins Running gehen - $this->latest = null; + $this->latest = null; $this->displayLatest = null; - $this->hasUpdate = false; - $this->state = 'running'; - $this->running = true; - $this->errorLine = null; + $this->hasUpdate = false; + $this->state = 'running'; + $this->running = true; + $this->rc = null; + $this->lowState = 'starting'; + $this->errorLine = null; $this->progressLine = 'Update gestartet …'; + $this->postActionsDone = false; $this->recomputeUi(); } @@ -306,10 +314,11 @@ class UpdateCard extends Component $this->lowState = $state !== '' ? $state : null; - // running: solange NICHT 'done' + // 'starting' = von runUpdate() gesetzt, bevor das Shell-Skript startet + // → gilt als "running", nicht als "done" $this->running = ($this->lowState !== 'done'); - // rc erst freigeben, wenn wirklich done + // rc erst freigeben wenn wirklich 'done' — verhindert Lesen von alten rc-Dateien $this->rc = ($this->lowState === 'done' && is_numeric($rcRaw)) ? (int)$rcRaw : null; $this->progressLine = $this->tailUpdateLog();