Signal priority sync work to an active warmup

This commit is contained in:
Terranom674
2026-09-03 12:54:52 +02:00
parent ccefc72c25
commit 714c487ef2

View File

@@ -112,6 +112,29 @@ foreach (bratonien_tools_nc_connector_connections() as $connection)
} }
} }
if ($mode === 'sync')
{
if (!is_dir($state_dir) && !@mkdir($state_dir, 0750, true) && !is_dir($state_dir))
{
fwrite(STDERR, "Warmup-Priorität für Verbindung #{$connection_id} konnte nicht signalisiert werden: State-Verzeichnis fehlt.\n");
$result = 1;
continue;
}
$priority_file = $state_dir.'/webdav-cache-warmup-priority-sync';
$priority_payload = json_encode(array(
'connection_id'=>$connection_id,
'requested_at'=>time(),
'reason'=>'connector-sync-complete',
), JSON_UNESCAPED_SLASHES);
if (!is_string($priority_payload) || @file_put_contents($priority_file, $priority_payload."\n", LOCK_EX) === false)
{
fwrite(STDERR, "Warmup-Priorität für Verbindung #{$connection_id} konnte nicht geschrieben werden.\n");
$result = 1;
continue;
}
@chmod($priority_file, 0664);
}
// Der Guard hält webdav-sync.lock für den gesamten Worker-Lauf geteilt. // 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, // Dadurch kann der produktive Source-/Shadow-Tree während Download, Swap,
// Piwigo-Aufruf und Restore nicht von einem Connector-Sync ersetzt werden. // Piwigo-Aufruf und Restore nicht von einem Connector-Sync ersetzt werden.