fix(launcher): skip url files in sync

This commit is contained in:
Scott Idem
2026-05-13 13:36:57 -04:00
parent 8d5c5e39c9
commit e5883cd53c
2 changed files with 16 additions and 3 deletions

View File

@@ -24,6 +24,16 @@ let sync_results: Record<string, 'success' | 'error' | 'pending'> = $state({});
let sync_stats = $state({ total: 0, cached: 0, missing: 0 });
let last_heartbeat: string | null = $state(null);
function is_url_file(file_obj: any): boolean {
const filename = (file_obj?.filename ?? '') as string;
const extension = (file_obj?.extension ?? '').toLowerCase();
return (
filename.startsWith('https://') ||
filename.startsWith('http://') ||
extension === 'url'
);
}
// Loop Timings (Visible in UI)
// WHY: Session was originally 15s which combined with the SWR background-refresh
// pattern caused a continuous API call every 15s even on cache hits. 60s is still
@@ -294,11 +304,13 @@ async function run_sync_cycle() {
.anyOf(all_for_ids)
.toArray();
sync_stats.total = files.length;
const cacheable_files = files.filter((file_obj) => !is_url_file(file_obj));
sync_stats.total = cacheable_files.length;
let cached_count = 0;
let missing_count = 0;
for (const file_obj of files) {
for (const file_obj of cacheable_files) {
// Re-check pause flag each iteration — a sync cycle can run for many
// seconds if there are missing files, so we must honour a pause request
// mid-loop rather than waiting for the entire batch to finish.

View File

@@ -110,7 +110,8 @@ let is_online: boolean = $state(typeof navigator !== 'undefined' ? navigator.onL
*/
const is_url = $derived(
(event_file_obj?.filename ?? '').startsWith('https://') ||
(event_file_obj?.filename ?? '').startsWith('http://')
(event_file_obj?.filename ?? '').startsWith('http://') ||
(event_file_obj?.extension ?? '').toLowerCase() === 'url'
);
let screen_saver_exts = ['jpg', 'png', 'PNG', 'webp'];