sync logs :D

This commit is contained in:
Lars Behrends
2025-10-19 14:54:33 +02:00
parent 7f13b180b9
commit 0f95458466
9 changed files with 184 additions and 35 deletions

View File

@@ -94,22 +94,22 @@ if ($source['name'] === 'jellyfin') {
$syncService = null;
switch ($source['name']) {
case 'steam':
$syncService = new SteamSyncService($pdo, $sourceData);
$syncService = new SteamSyncService($pdo, $sourceData, $syncLogId);
break;
case 'jellyfin':
$syncService = new JellyfinSyncService($pdo, $sourceData);
$syncService = new JellyfinSyncService($pdo, $sourceData, $syncLogId);
break;
case 'stash':
$syncService = new StashSyncService($pdo, $sourceData);
$syncService = new StashSyncService($pdo, $sourceData, $syncLogId);
break;
case 'adult':
$syncService = new AdultSyncService($pdo, $sourceData);
$syncService = new AdultSyncService($pdo, $sourceData, $syncLogId);
break;
case 'xbvr':
$syncService = new XbvrSyncService($pdo, $sourceData);
$syncService = new XbvrSyncService($pdo, $sourceData, $syncLogId);
break;
case 'exophase':
$syncService = new ExophaseSyncService($pdo, $sourceData);
$syncService = new ExophaseSyncService($pdo, $sourceData, $syncLogId);
break;
default:
echo "Unsupported source type: " . $source['name'] . "\n";
@@ -134,11 +134,11 @@ $syncLogModel->update($syncLogId, [
// Execute the sync
try {
$syncLogId = $syncService->startSync($syncType);
$returnedSyncLogId = $syncService->startSync($syncType);
if (!$noOutput) {
echo "Sync started with log ID: {$syncLogId}\n";
echo "Monitor progress at: /admin/sync/status/{$syncLogId}\n";
echo "Sync started with log ID: {$returnedSyncLogId}\n";
echo "Monitor progress at: /admin/sync/status/{$returnedSyncLogId}\n";
echo "Sync completed successfully.\n";
}
@@ -150,8 +150,10 @@ try {
echo "File: " . $e->getFile() . ":" . $e->getLine() . "\n";
}
// Update sync log as failed
$syncLogModel->update($syncLogId, [
// Update sync log as failed (use the returned ID or fall back to original)
$failedSyncLogId = $returnedSyncLogId ?? $syncLogId;
$syncLogModel = new SyncLog($pdo);
$syncLogModel->update($failedSyncLogId, [
'status' => 'failed',
'completed_at' => date('Y-m-d H:i:s'),
'message' => $e->getMessage(),