Fix: Update-UI zeigt alte Version / schließt sofort ab (Race Condition)
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 <noreply@anthropic.com>main v1.1.276
parent
bd7bb50a52
commit
240c672198
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue