From 87647f8f1637e8bfe9e06bbee123cbb965d14517 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Thu, 3 Sep 2026 12:50:23 +0200 Subject: [PATCH] Hold connector sync guard for full warmup run --- runtime/webdav-warmup-dispatch.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/runtime/webdav-warmup-dispatch.php b/runtime/webdav-warmup-dispatch.php index b996c84..1f3766f 100644 --- a/runtime/webdav-warmup-dispatch.php +++ b/runtime/webdav-warmup-dispatch.php @@ -56,11 +56,17 @@ if (!function_exists('exec')) } $worker = realpath(BRATONIEN_TOOLS_PATH.'runtime/lib/webdav-cache-warmup.php'); +$guard = realpath(BRATONIEN_TOOLS_PATH.'runtime/lib/run-webdav-cache-warmup.sh'); if (!$worker || !is_file($worker)) { fwrite(STDERR, "WebDAV-Cache-Warmup-Worker wurde nicht gefunden.\n"); exit(1); } +if (!$guard || !is_file($guard)) +{ + fwrite(STDERR, "WebDAV-Cache-Warmup-Schutzskript wurde nicht gefunden.\n"); + exit(1); +} $log = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'bratonien-webdav-warmup.log'; $result = 0; @@ -71,7 +77,20 @@ foreach (bratonien_tools_nc_connector_connections() as $connection) $connection_id = (int)$connection['id']; if ($connection_id < 1) continue; - $base = escapeshellarg(PHP_BINARY).' '.escapeshellarg($worker) + $config = isset($connection['config']) && is_array($connection['config']) ? $connection['config'] : array(); + $state_dir = rtrim((string)($config['state_dir'] ?? ''), '/'); + if ($state_dir === '') + { + fwrite(STDERR, "Warmup für Verbindung #{$connection_id} übersprungen: Connector-State-Verzeichnis fehlt.\n"); + $result = 1; + continue; + } + + // Der Guard hält webdav-sync.lock für den gesamten Worker-Lauf geteilt. + // Dadurch kann der produktive Source-/Shadow-Tree während Download, Swap, + // Piwigo-Aufruf und Restore nicht von einem Connector-Sync ersetzt werden. + $base = escapeshellarg('/bin/bash').' '.escapeshellarg($guard).' '.escapeshellarg($state_dir) + .' '.escapeshellarg(PHP_BINARY).' '.escapeshellarg($worker) .' --connection-id='.$connection_id .' --mode='.escapeshellarg($mode);