diff --git a/app/Livewire/Ui/System/Modal/UpdateModal.php b/app/Livewire/Ui/System/Modal/UpdateModal.php index 5c2fc21..b4fba43 100644 --- a/app/Livewire/Ui/System/Modal/UpdateModal.php +++ b/app/Livewire/Ui/System/Modal/UpdateModal.php @@ -34,12 +34,24 @@ class UpdateModal extends ModalComponent $st = @trim(@file_get_contents(self::STATE_DIR.'/state') ?: ''); $rcRaw = @trim(@file_get_contents(self::STATE_DIR.'/rc') ?: ''); + // Log einlesen + $lines = @file(self::LOG, FILE_IGNORE_NEW_LINES) ?: []; + + // Nur als "done" gelten wenn [DONE]-Marker im Log steht — + // verhindert dass das Modal fertig zeigt während das Script noch läuft + $logDone = in_array('[DONE]', array_map('trim', $lines), true); + + if ($st === 'done' && !$logDone) { + $st = 'running'; // Noch warten bis Log vollständig + } + $this->state = $st ?: 'unknown'; $this->rc = is_numeric($rcRaw) ? (int)$rcRaw : null; - // Log einlesen - $lines = @file(self::LOG, FILE_IGNORE_NEW_LINES) ?: []; - $this->tail = array_slice($lines, -30); + $this->tail = array_slice( + array_filter($lines, fn($l) => trim($l) !== '[DONE]'), + -30 + ); $last = trim($this->tail ? end($this->tail) : ''); $last = preg_replace('/^\[\w\]\s*/', '', $last); diff --git a/scripts/update.sh b/scripts/update.sh index 23a84d5..e9c451c 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -369,10 +369,10 @@ _cleanup() { sudo -u "${APP_USER}" php "${APP_DIR}/artisan" optimize:clear 2>&1 || true sudo -u "${APP_USER}" php "${APP_DIR}/artisan" optimize 2>&1 || true fi - # Kurz warten damit das tee-Pipe den Log vollständig schreibt - # bevor der State auf "done" gesetzt wird - sleep 2 + # [DONE] direkt ins Log-File schreiben (am tee-Pipe vorbei) damit + # die Reihenfolge garantiert ist: Log hat [DONE] bevor state=done sichtbar ist mkdir -p "$STATE_DIR" + printf '[DONE]\n' >> "$LOG_FILE" 2>/dev/null || true echo "done" > "$STATE_DIR/state" echo "$rc" > "$STATE_DIR/rc" rm -f "$LOCK_FILE"