diff --git a/apps/app/src/library/EventSettings.tsx b/apps/app/src/library/EventSettings.tsx index a7a889a..cf0c5f5 100644 --- a/apps/app/src/library/EventSettings.tsx +++ b/apps/app/src/library/EventSettings.tsx @@ -36,6 +36,8 @@ export function EventSettingsButton(props: { const [startsAt, setStartsAt] = useState(isoToLisbonLocal(event.startsAt)); const [from, setFrom] = useState(isoToLisbonLocal(event.ingestFrom)); const [to, setTo] = useState(isoToLisbonLocal(event.ingestUntil)); + const [homeShort, setHomeShort] = useState(event.homeShort ?? ""); + const [awayShort, setAwayShort] = useState(event.awayShort ?? ""); const [people, setPeople] = useState< { id: string; name: string; role: string }[] >([]); @@ -51,6 +53,8 @@ export function EventSettingsButton(props: { setFrom(isoToLisbonLocal(event.ingestFrom)); setTo(isoToLisbonLocal(event.ingestUntil)); setChosen(new Set(event.photographers.map((p) => p.id))); + setHomeShort(event.homeShort ?? ""); + setAwayShort(event.awayShort ?? ""); setConfirm(false); }, [event]); @@ -105,6 +109,7 @@ export function EventSettingsButton(props: { ingestFrom: lisbonLocalToIso(from), ingestUntil: lisbonLocalToIso(to), photographerIds: [...chosen], + ...(event.away ? { homeShort: homeShort.trim() || null, awayShort: awayShort.trim() || null } : {}), }), ); }); @@ -219,6 +224,31 @@ export function EventSettingsButton(props: { /> + {event.away && ( + /* Siglas curtas para as pastas de entrega (ex.: CDE x CDF); vazio usa o nome completo. Labels inline: i18n.ts por agora noutra branch. */ +
+ + +
+ )}
{L.photographers} {people.map((p) => ( diff --git a/apps/app/src/library/Grid.tsx b/apps/app/src/library/Grid.tsx index f85d65d..3797519 100644 --- a/apps/app/src/library/Grid.tsx +++ b/apps/app/src/library/Grid.tsx @@ -31,6 +31,8 @@ const Cell = memo(function Cell({ photo, index, src, selected, focused, onPick, const label = LABEL_COLOR[photo.colorLabel]; // Desktop app: thumbnails are kept on the computer, so the grid shows without a network. const shown = useCachedImage(src, isDesktop()); + const [imgFailed, setImgFailed] = useState(false); + useEffect(() => setImgFailed(false), [shown]); return ( + {pickOpen && ( +
+ {targets.map((x) => ( + + ))} +
+ )} + )} )} diff --git a/apps/app/src/offline/cache.ts b/apps/app/src/offline/cache.ts index c957336..b0b6487 100644 --- a/apps/app/src/offline/cache.ts +++ b/apps/app/src/offline/cache.ts @@ -48,6 +48,20 @@ async function slot(fn: () => Promise): Promise { } } +/** How long to wait for a single image download before giving up its slot. */ +const FETCH_TIMEOUT_MS = 20000; + +/** fetch that aborts if it stalls, so one hung request can't hold a concurrency slot forever and starve the grid. */ +async function fetchWithTimeout(url: string): Promise { + const ctrl = new AbortController(); + const timer = setTimeout(() => ctrl.abort(), FETCH_TIMEOUT_MS); + try { + return await fetch(url, { signal: ctrl.signal }); + } finally { + clearTimeout(timer); + } +} + /** * The image as a blob URL: from this computer when it was seen before, else downloaded once and kept. Null when it * can't be had (offline and never seen). The caller revokes the URL when done. @@ -59,7 +73,7 @@ export async function cachedImage(url: string): Promise { if (kept) return URL.createObjectURL(kept); try { const blob = await slot(async () => { - const res = await fetch(url); + const res = await fetchWithTimeout(url); if (!res.ok) throw new Error(`http_${res.status}`); return res.blob(); }); diff --git a/apps/desktop/src-tauri/src/ftp.rs b/apps/desktop/src-tauri/src/ftp.rs index b5d14e6..432e505 100644 --- a/apps/desktop/src-tauri/src/ftp.rs +++ b/apps/desktop/src-tauri/src/ftp.rs @@ -13,6 +13,7 @@ use std::collections::{HashMap, HashSet}; use std::net::IpAddr; use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::{Arc, Mutex}; use std::time::UNIX_EPOCH; @@ -158,6 +159,8 @@ pub struct FtpState { /// Paths already handed to the web app (so the next scan does not send them twice). taken: Mutex>, last_error: Arc>>, + /// Bumped on every start/stop so a stopped server's late "shutdown" error can't land on a newer one. + epoch: Arc, checks: Mutex>, firewall: Mutex>, } @@ -549,9 +552,15 @@ impl FtpState { *self.last_error.lock().unwrap() = None; let last_error = self.last_error.clone(); + let epoch = self.epoch.clone(); + let generation = epoch.fetch_add(1, Ordering::SeqCst) + 1; tauri::async_runtime::spawn(async move { if let Err(e) = server.listen(format!("0.0.0.0:{port}")).await { - *last_error.lock().unwrap() = Some(e.to_string()); + // Only this server's own failure counts: once it has been stopped or replaced + // (the epoch has moved on), its expected shutdown must not overwrite a newer server's status. + if epoch.load(Ordering::SeqCst) == generation { + *last_error.lock().unwrap() = Some(e.to_string()); + } } }); *self.running.lock().unwrap() = Some(Running { stop: stop_tx }); @@ -560,7 +569,11 @@ impl FtpState { pub fn stop(&self) { if let Some(r) = self.running.lock().unwrap().take() { + // Move the epoch on so this server's own shutdown is ignored by its listen task, and clear the + // error: a server we stopped on purpose is not a server in error. + self.epoch.fetch_add(1, Ordering::SeqCst); let _ = r.stop.send(()); + *self.last_error.lock().unwrap() = None; } self.checks.lock().unwrap().clear(); } diff --git a/packages/metadata/src/metadata.test.ts b/packages/metadata/src/metadata.test.ts index 7b3d223..2845c7f 100644 --- a/packages/metadata/src/metadata.test.ts +++ b/packages/metadata/src/metadata.test.ts @@ -138,8 +138,10 @@ describe("vars", () => { describe("delivery paths", () => { const vsc = buildVars({ - home: "VSC", - away: "AAAS", + home: "Vitória SC", + away: "AA Águas Santas", + homeShort: "VSC", + awayShort: "AAAS", competition: "Campeonato Betclic", competitionCode: "PO01", startsAt: new Date("2026-09-23T19:00:00Z"), diff --git a/packages/metadata/src/paths.ts b/packages/metadata/src/paths.ts index 9c79af4..f37f914 100644 --- a/packages/metadata/src/paths.ts +++ b/packages/metadata/src/paths.ts @@ -68,8 +68,8 @@ export function renderFileName(template: string, vars: TemplateVars, originalFil /** Example destination rules taken from today's deliveries. */ export const DESTINATION_EXAMPLES = { fpa: { - folder: "/FPA/Fotos/{season}/Competições Nacionais/{competitionCode} - {competition}/{dateCompact} - {home} x {away}/", - fileName: "PS_{home} x {away}_{n}.jpg", + folder: "/FPA/Fotos/{season}/Competições Nacionais/{competitionCode} - {competition}/{dateCompact} - {homeShort} x {awayShort}/", + fileName: "PS_{homeShort} x {awayShort}_{n}.jpg", }, liga: { folder: "/LPBetclic {seasonShort}/Jornada {round}/{matchNumber}. {home} x {away}/",