Fix: ClamAV starting-State überlebt Reload + kein false-dirty bei untracked

Flag-Datei /tmp/mw-clamav-starting speichert Startzeitpunkt sodass
Spinner + Timer auch nach Seitenreload korrekt weiterläuft.
git_dirty_check filtert jetzt untracked Dateien (??) heraus damit
mailwolt-installer/ und ähnliche nicht fälschlich als dirty gelten.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main v1.1.337
boban 2026-04-26 21:11:55 +02:00
parent 2331ef74f6
commit 3f6f787fd3
2 changed files with 24 additions and 2 deletions

View File

@ -23,9 +23,28 @@ class ClamavManager extends Component
public bool $starting = false;
public int $startSecs = 0;
private const STARTING_FLAG = '/tmp/mw-clamav-starting';
public function mount(): void
{
$this->refresh();
$this->restoreStartingState();
}
private function restoreStartingState(): void
{
if (!file_exists(self::STARTING_FLAG)) return;
if ($this->running) {
@unlink(self::STARTING_FLAG);
return;
}
$elapsed = time() - (int) @file_get_contents(self::STARTING_FLAG);
if ($elapsed > 180) {
@unlink(self::STARTING_FLAG);
return;
}
$this->starting = true;
$this->startSecs = max(0, $elapsed);
}
public function refresh(): void
@ -56,8 +75,9 @@ class ClamavManager extends Component
public function enable(): void
{
$this->lastError = '';
$this->lastError = '';
$this->lastSuccess = '';
file_put_contents(self::STARTING_FLAG, time());
ClamavEnable::dispatch();
$this->enabled = true;
$this->starting = true;
@ -70,6 +90,7 @@ class ClamavManager extends Component
$this->startSecs += 3;
$this->running = $this->serviceActive();
if ($this->running) {
@unlink(self::STARTING_FLAG);
$this->starting = false;
$this->startSecs = 0;
$this->enabled = $this->serviceEnabled();

View File

@ -75,8 +75,9 @@ git_safe(){
git_dirty_check(){
# Als root ausführen: kein Permission-Problem unabhängig vom Dateieigentümer
# Nur tracked Änderungen prüfen untracked Dateien (??) ignorieren
local dirty
dirty="$(git -C "${APP_DIR}" status --porcelain 2>/dev/null || true)"
dirty="$(git -C "${APP_DIR}" status --porcelain 2>/dev/null | grep -v '^??' || true)"
if [[ -n "$dirty" ]]; then
echo "[!] Uncommitted Änderungen — tracked Dateien werden zurückgesetzt:"
echo "$dirty"