Hold connector sync guard for full warmup run

This commit is contained in:
Terranom674
2026-09-03 12:50:23 +02:00
parent 362229efaa
commit 87647f8f16

View File

@@ -56,11 +56,17 @@ if (!function_exists('exec'))
} }
$worker = realpath(BRATONIEN_TOOLS_PATH.'runtime/lib/webdav-cache-warmup.php'); $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)) if (!$worker || !is_file($worker))
{ {
fwrite(STDERR, "WebDAV-Cache-Warmup-Worker wurde nicht gefunden.\n"); fwrite(STDERR, "WebDAV-Cache-Warmup-Worker wurde nicht gefunden.\n");
exit(1); 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'; $log = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'bratonien-webdav-warmup.log';
$result = 0; $result = 0;
@@ -71,7 +77,20 @@ foreach (bratonien_tools_nc_connector_connections() as $connection)
$connection_id = (int)$connection['id']; $connection_id = (int)$connection['id'];
if ($connection_id < 1) continue; 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 .' --connection-id='.$connection_id
.' --mode='.escapeshellarg($mode); .' --mode='.escapeshellarg($mode);