isDot() || !$entry->isDir()) { continue; } if (preg_match('/^user_(\d+)$/', $entry->getFilename(), $matches)) { $targetPersonIds[] = (int) $matches[1]; } } } $targetPersonIds = array_values(array_unique($targetPersonIds)); sort($targetPersonIds); if (empty($targetPersonIds)) { fwrite(STDOUT, "No user workspace directories detected; nothing to sync.\n"); exit(0); } fwrite(STDOUT, "Preparing workspaces for person IDs: " . implode(', ', $targetPersonIds) . "\n"); $exitCode = 0; foreach ($targetPersonIds as $personId) { try { $result = $dataSourceManager->prepareJupyterWorkspace($personId, $workspaceRoot); $syncedCount = count($result['synced'] ?? []); $missingCount = count($result['missing'] ?? []); fwrite( STDOUT, sprintf( "✔ person_id=%d synced=%d missing=%d dir=%s\n", $personId, $syncedCount, $missingCount, $result['workspace_dir'] ?? 'N/A' ) ); } catch (Throwable $e) { fwrite( STDERR, sprintf( "✖ person_id=%d failed: %s\n", $personId, $e->getMessage() ) ); $exitCode = 1; } } exit($exitCode);