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();