Fix: Mailbox Stats über Dovecot mit config/mailpool.php

main v1.0.63
boban 2025-10-26 20:33:53 +01:00
parent d65aaf9a5d
commit 8e35c617b8
3 changed files with 56 additions and 25 deletions

View File

@ -38,11 +38,8 @@ class RunHealthChecks implements ShouldQueue
// Cache::put(CacheVer::k('health:services'), $svcRows, 60);
$payload = ['ts' => time(), 'rows' => $svcRows];
Cache::put(CacheVer::k('health:services'), $payload, 300);
Cache::put('health:services', $svcRows, 300);
Setting::set('woltguard.services', $payload);
}
/** Wraps a probe; logs and returns fallback on error */

View File

@ -90,6 +90,10 @@ class UpdateCard extends Component
// 1) aktuellen Wrapper-Status einlesen
$this->refreshLowLevelState();
if ($this->rc !== null) {
$this->running = false;
}
// 2) Failsafe
$started = (int)Cache::get($this->cacheStartedAtKey, 0);
if ($this->running && $started > 0 && (time() - $started) > $this->failsafeSeconds) {
@ -235,12 +239,24 @@ class UpdateCard extends Component
protected function refreshLowLevelState(): void
{
$state = @trim(@file_get_contents('/var/lib/mailwolt/update/state') ?: '');
$this->running = ($state === 'running');
$rcRaw = @trim(@file_get_contents('/var/lib/mailwolt/update/rc') ?: '');
$this->rc = is_numeric($rcRaw) ? (int)$rcRaw : null;
// ← harte Wahrheit: Sobald es eine rc gibt, ist es NICHT mehr running
// selbst wenn "state" (noch) "running" enthält.
$this->running = ($this->rc === null) && ($state !== 'done');
// optional: letzte Logzeile für die UI
$this->progressLine = $this->tailUpdateLog();
// $state = @trim(@file_get_contents('/var/lib/mailwolt/update/state') ?: '');
// $this->running = ($state === 'running');
//
// $rcRaw = @trim(@file_get_contents('/var/lib/mailwolt/update/rc') ?: '');
// $this->rc = is_numeric($rcRaw) ? (int)$rcRaw : null;
//
// $this->progressLine = $this->tailUpdateLog();
}
protected function readCurrentVersion(): ?string

View File

@ -49,31 +49,49 @@ class WoltguardCard extends Component
protected function load(): void
{
// 1) Versionierter Key holen
$val = Cache::get(\App\Support\CacheVer::k('health:services'));
// $val = Cache::get(\App\Support\CacheVer::k('health:services'));
//
// // 2) Falls leer → Legacy-Key (altes Format: direkt die Rows)
// if (empty($val)) {
// $legacy = Cache::get('health:services', []);
// if (!empty($legacy) && is_array($legacy)) {
// $val = ['ts' => null, 'rows' => $legacy];
// }
// }
//
// // 3) DB-Fallback (Settings), wenn weiterhin leer
// if (empty($val)) {
// $val = \App\Models\Setting::get('woltguard.services'); // erwartet ['ts'=>..,'rows'=>[..]]
// }
//
// // 4) Shape normalisieren
// $rows = [];
// if (is_array($val)) {
// // neues Format
// if (array_key_exists('rows', $val) && is_array($val['rows'])) {
// $rows = $val['rows'];
// }
// // falls jemand doch wieder nur die Rows speichert
// elseif (isset($val[0]) && is_array($val[0]) && array_key_exists('name', $val[0])) {
// $rows = $val;
// }
// }
// 2) Falls leer → Legacy-Key (altes Format: direkt die Rows)
if (empty($val)) {
$legacy = Cache::get('health:services', []);
if (!empty($legacy) && is_array($legacy)) {
$val = ['ts' => null, 'rows' => $legacy];
}
$list = Cache::get(CacheVer::k('health:services'));
if (empty($list)) {
// Fallback: aus DB/Redis (persistiert vom Job)
$list = \App\Support\Setting::get('woltguard.services', []);
}
// 3) DB-Fallback (Settings), wenn weiterhin leer
if (empty($val)) {
$val = \App\Models\Setting::get('woltguard.services'); // erwartet ['ts'=>..,'rows'=>[..]]
}
// 4) Shape normalisieren
$rows = [];
if (is_array($val)) {
// neues Format
if (array_key_exists('rows', $val) && is_array($val['rows'])) {
$rows = $val['rows'];
if (is_array($list)) {
// neues Format: ['ts'=>..., 'rows'=>[...]]
if (isset($list['rows']) && is_array($list['rows'])) {
$rows = $list['rows'];
}
// falls jemand doch wieder nur die Rows speichert
elseif (isset($val[0]) && is_array($val[0]) && array_key_exists('name', $val[0])) {
$rows = $val;
// altes Format: direkt die Array-Liste
elseif (isset($list[0]) && is_array($list[0])) {
$rows = $list;
}
}