fix(launcher): skip url files in sync
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user