Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e2a5b482e | ||
|
|
8d12e7c995 | ||
|
|
1702c290de | ||
|
|
03df893e34 | ||
|
|
d756d13d69 | ||
|
|
53d8194cd5 |
No files matched your search
@@ -36,6 +36,8 @@ export function EventSettingsButton(props: {
|
|||||||
const [startsAt, setStartsAt] = useState(isoToLisbonLocal(event.startsAt));
|
const [startsAt, setStartsAt] = useState(isoToLisbonLocal(event.startsAt));
|
||||||
const [from, setFrom] = useState(isoToLisbonLocal(event.ingestFrom));
|
const [from, setFrom] = useState(isoToLisbonLocal(event.ingestFrom));
|
||||||
const [to, setTo] = useState(isoToLisbonLocal(event.ingestUntil));
|
const [to, setTo] = useState(isoToLisbonLocal(event.ingestUntil));
|
||||||
|
const [homeShort, setHomeShort] = useState(event.homeShort ?? "");
|
||||||
|
const [awayShort, setAwayShort] = useState(event.awayShort ?? "");
|
||||||
const [people, setPeople] = useState<
|
const [people, setPeople] = useState<
|
||||||
{ id: string; name: string; role: string }[]
|
{ id: string; name: string; role: string }[]
|
||||||
>([]);
|
>([]);
|
||||||
@@ -51,6 +53,8 @@ export function EventSettingsButton(props: {
|
|||||||
setFrom(isoToLisbonLocal(event.ingestFrom));
|
setFrom(isoToLisbonLocal(event.ingestFrom));
|
||||||
setTo(isoToLisbonLocal(event.ingestUntil));
|
setTo(isoToLisbonLocal(event.ingestUntil));
|
||||||
setChosen(new Set(event.photographers.map((p) => p.id)));
|
setChosen(new Set(event.photographers.map((p) => p.id)));
|
||||||
|
setHomeShort(event.homeShort ?? "");
|
||||||
|
setAwayShort(event.awayShort ?? "");
|
||||||
setConfirm(false);
|
setConfirm(false);
|
||||||
}, [event]);
|
}, [event]);
|
||||||
|
|
||||||
@@ -105,6 +109,7 @@ export function EventSettingsButton(props: {
|
|||||||
ingestFrom: lisbonLocalToIso(from),
|
ingestFrom: lisbonLocalToIso(from),
|
||||||
ingestUntil: lisbonLocalToIso(to),
|
ingestUntil: lisbonLocalToIso(to),
|
||||||
photographerIds: [...chosen],
|
photographerIds: [...chosen],
|
||||||
|
...(event.away ? { homeShort: homeShort.trim() || null, awayShort: awayShort.trim() || null } : {}),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -219,6 +224,31 @@ export function EventSettingsButton(props: {
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
{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. */
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<label className="block">
|
||||||
|
<span className="text-faint">Sigla casa</span>
|
||||||
|
<input
|
||||||
|
value={homeShort}
|
||||||
|
onChange={(e) => setHomeShort(e.target.value)}
|
||||||
|
placeholder={event.home}
|
||||||
|
maxLength={20}
|
||||||
|
className={input}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="block">
|
||||||
|
<span className="text-faint">Sigla visitante</span>
|
||||||
|
<input
|
||||||
|
value={awayShort}
|
||||||
|
onChange={(e) => setAwayShort(e.target.value)}
|
||||||
|
placeholder={event.away}
|
||||||
|
maxLength={20}
|
||||||
|
className={input}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<fieldset className="space-y-1">
|
<fieldset className="space-y-1">
|
||||||
<legend className="text-faint">{L.photographers}</legend>
|
<legend className="text-faint">{L.photographers}</legend>
|
||||||
{people.map((p) => (
|
{people.map((p) => (
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ const Cell = memo(function Cell({ photo, index, src, selected, focused, onPick,
|
|||||||
const label = LABEL_COLOR[photo.colorLabel];
|
const label = LABEL_COLOR[photo.colorLabel];
|
||||||
// Desktop app: thumbnails are kept on the computer, so the grid shows without a network.
|
// Desktop app: thumbnails are kept on the computer, so the grid shows without a network.
|
||||||
const shown = useCachedImage(src, isDesktop());
|
const shown = useCachedImage(src, isDesktop());
|
||||||
|
const [imgFailed, setImgFailed] = useState(false);
|
||||||
|
useEffect(() => setImgFailed(false), [shown]);
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
ref={ref}
|
ref={ref}
|
||||||
@@ -49,7 +51,13 @@ const Cell = memo(function Cell({ photo, index, src, selected, focused, onPick,
|
|||||||
</span>
|
</span>
|
||||||
<span className="flex min-h-0 w-full flex-1 items-center justify-center">
|
<span className="flex min-h-0 w-full flex-1 items-center justify-center">
|
||||||
{photo.status === "READY" ? (
|
{photo.status === "READY" ? (
|
||||||
shown && <img src={shown} alt="" loading="lazy" decoding="async" draggable={false} className="max-h-full max-w-full object-contain shadow-[0_1px_3px_rgba(0,0,0,0.6)]" />
|
imgFailed ? (
|
||||||
|
<span className="font-mono text-[10px] uppercase text-faint">erro</span>
|
||||||
|
) : shown ? (
|
||||||
|
<img src={shown} onError={() => setImgFailed(true)} alt="" loading="lazy" decoding="async" draggable={false} className="max-h-full max-w-full object-contain shadow-[0_1px_3px_rgba(0,0,0,0.6)]" />
|
||||||
|
) : (
|
||||||
|
<span className="font-mono text-[10px] uppercase text-faint">…</span>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<span className="font-mono text-[10px] uppercase text-faint">{photo.status === "FAILED" ? "erro" : "…"}</span>
|
<span className="font-mono text-[10px] uppercase text-faint">{photo.status === "FAILED" ? "erro" : "…"}</span>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -10,25 +10,51 @@ import { ZerozeroGamePicker } from "./ZerozeroGame.js";
|
|||||||
const LAST_TARGET = "deliver.target";
|
const LAST_TARGET = "deliver.target";
|
||||||
const BEST_COUNT = "deliver.bestCount";
|
const BEST_COUNT = "deliver.bestCount";
|
||||||
|
|
||||||
|
/** The saved destinations: a list now, but older versions saved one id, so both are read. */
|
||||||
|
function savedTargets(): string[] {
|
||||||
|
const raw = prefs.get(LAST_TARGET) ?? "";
|
||||||
|
if (!raw) return [];
|
||||||
|
try {
|
||||||
|
const v = JSON.parse(raw);
|
||||||
|
if (Array.isArray(v)) return v.filter((x): x is string => typeof x === "string");
|
||||||
|
} catch {
|
||||||
|
/* an older single-id value */
|
||||||
|
}
|
||||||
|
return [raw];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Photo Mechanic's Upload Photos, in the library's top bar: sends the selected photos (rejects never) to a
|
* Photo Mechanic's Upload Photos, in the library's top bar: sends the selected photos (rejects never) to one or
|
||||||
* destination. With no destination yet it leads to where one is set up.
|
* more destinations at once. With no destination yet it leads to where one is set up.
|
||||||
*/
|
*/
|
||||||
export function SendButton(props: { api: ApiClient; orgId: string; selection: PhotoSummary[]; targets: DeliveryTarget[]; eventId?: string | null; onQueued: (items: DeliveryItemSummary[]) => void }) {
|
export function SendButton(props: { api: ApiClient; orgId: string; selection: PhotoSummary[]; targets: DeliveryTarget[]; eventId?: string | null; onQueued: (items: DeliveryItemSummary[]) => void }) {
|
||||||
const { api, orgId, selection, targets, eventId } = props;
|
const { api, orgId, selection, targets, eventId } = props;
|
||||||
const [bestOpen, setBestOpen] = useState(false);
|
const [bestOpen, setBestOpen] = useState(false);
|
||||||
const [bestCount, setBestCount] = useState(() => Number(prefs.get(BEST_COUNT)) || 30);
|
const [bestCount, setBestCount] = useState(() => Number(prefs.get(BEST_COUNT)) || 30);
|
||||||
const [bestAgain, setBestAgain] = useState(false);
|
const [bestAgain, setBestAgain] = useState(false);
|
||||||
/** Photos the last send skipped because this destination already has them: offered to send again. */
|
/** Photos the last send skipped because a destination already has them: offered to send again. */
|
||||||
const [already, setAlready] = useState<string[]>([]);
|
const [already, setAlready] = useState<string[]>([]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [targetId, setTargetId] = useState(() => prefs.get(LAST_TARGET) ?? "");
|
const [chosenTargets, setChosenTargets] = useState<string[]>(savedTargets);
|
||||||
|
const [pickOpen, setPickOpen] = useState(false);
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [note, setNote] = useState<string | null>(null);
|
const [note, setNote] = useState<string | null>(null);
|
||||||
|
|
||||||
|
/** Remember the chosen destinations across tabs and restarts (persisted on every change, not only on send). */
|
||||||
|
const remember = (ids: string[]) => {
|
||||||
|
setChosenTargets(ids);
|
||||||
|
prefs.set(LAST_TARGET, JSON.stringify(ids));
|
||||||
|
};
|
||||||
|
|
||||||
|
// Drop destinations that no longer exist; with none left, start on the first available one.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (targets.length && !targets.some((x) => x.id === targetId)) setTargetId(targets[0]!.id);
|
if (!targets.length) return;
|
||||||
}, [targets, targetId]);
|
const valid = chosenTargets.filter((id) => targets.some((x) => x.id === id));
|
||||||
useEffect(() => setAlready([]), [targetId, eventId]);
|
if (valid.length !== chosenTargets.length || valid.length === 0) remember(valid.length ? valid : [targets[0]!.id]);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [targets]);
|
||||||
|
|
||||||
|
useEffect(() => setAlready([]), [chosenTargets, eventId]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!note) return;
|
if (!note) return;
|
||||||
const timer = setTimeout(() => setNote(null), 5000);
|
const timer = setTimeout(() => setNote(null), 5000);
|
||||||
@@ -43,16 +69,28 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selected = targets.filter((x) => chosenTargets.includes(x.id));
|
||||||
|
const selectedLabel = selected.map((x) => x.name).join(", ");
|
||||||
const photos = selection.filter((p) => p.flag !== "REJECT" && p.status === "READY");
|
const photos = selection.filter((p) => p.flag !== "REJECT" && p.status === "READY");
|
||||||
|
|
||||||
|
const toggle = (id: string) => {
|
||||||
|
const next = chosenTargets.includes(id) ? chosenTargets.filter((x) => x !== id) : [...chosenTargets, id];
|
||||||
|
remember(next.length ? next : [id]); // keep at least one chosen
|
||||||
|
};
|
||||||
|
|
||||||
const send = async (ids = photos.map((p) => p.id), again = false) => {
|
const send = async (ids = photos.map((p) => p.id), again = false) => {
|
||||||
|
if (!selected.length) return;
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
try {
|
try {
|
||||||
// Without a network (or photos still uploading) the request waits on this computer and goes when it can.
|
// Without a network (or photos still uploading) each request waits on this computer and goes when it can.
|
||||||
const r = await deliver(api, orgId, targetId, ids, again);
|
const results: Awaited<ReturnType<typeof deliver>>[] = [];
|
||||||
prefs.set(LAST_TARGET, targetId);
|
for (const target of selected) results.push(await deliver(api, orgId, target.id, ids, again));
|
||||||
props.onQueued(r.queued);
|
const queued = results.flatMap((r) => r.queued);
|
||||||
setAlready(r.skipped.filter((s) => s.reason === "already_delivered").map((s) => s.photoId));
|
const skipped = results.flatMap((r) => r.skipped);
|
||||||
setNote(r.waiting ? t.offline.queuedDelivery : t.delivered(r.queued.length, r.skipped.length));
|
const waiting = results.some((r) => r.waiting);
|
||||||
|
props.onQueued(queued);
|
||||||
|
setAlready([...new Set(skipped.filter((s) => s.reason === "already_delivered").map((s) => s.photoId))]);
|
||||||
|
setNote(waiting ? t.offline.queuedDelivery : t.delivered(queued.length, skipped.length));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setNote(err instanceof ApiError ? err.code : t.unexpectedError);
|
setNote(err instanceof ApiError ? err.code : t.unexpectedError);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -60,19 +98,21 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const target = targets.find((x) => x.id === targetId);
|
|
||||||
// Only the best of the open event: a short gallery of game moments, spread over the match.
|
// Only the best of the open event: a short gallery of game moments, spread over the match.
|
||||||
const sendBest = async () => {
|
const sendBest = async () => {
|
||||||
if (!eventId) return;
|
if (!eventId || !selected.length) return;
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
try {
|
try {
|
||||||
const r = await api.deliverBest(orgId, { targetId, eventId, count: bestCount, again: bestAgain });
|
const results: Awaited<ReturnType<ApiClient["deliverBest"]>>[] = [];
|
||||||
prefs.set(LAST_TARGET, targetId);
|
for (const target of selected) results.push(await api.deliverBest(orgId, { targetId: target.id, eventId, count: bestCount, again: bestAgain }));
|
||||||
prefs.set(BEST_COUNT, String(bestCount));
|
prefs.set(BEST_COUNT, String(bestCount));
|
||||||
props.onQueued(r.queued);
|
const queued = results.flatMap((r) => r.queued);
|
||||||
setAlready(r.skipped.filter((s) => s.reason === "already_delivered").map((s) => s.photoId));
|
const skipped = results.flatMap((r) => r.skipped);
|
||||||
|
const chosen = results[0]?.chosen ?? [];
|
||||||
|
props.onQueued(queued);
|
||||||
|
setAlready([...new Set(skipped.filter((s) => s.reason === "already_delivered").map((s) => s.photoId))]);
|
||||||
setBestOpen(false);
|
setBestOpen(false);
|
||||||
setNote(r.chosen.length ? t.bestSent(r.queued.length, r.chosen.length) : t.bestNone);
|
setNote(chosen.length ? t.bestSent(queued.length, chosen.length) : t.bestNone);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setNote(err instanceof ApiError ? err.code : t.unexpectedError);
|
setNote(err instanceof ApiError ? err.code : t.unexpectedError);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -82,20 +122,35 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="relative flex items-center gap-1">
|
<span className="relative flex items-center gap-1">
|
||||||
{target?.kind === "ZEROZERO" && eventId && <ZerozeroGamePicker api={api} orgId={orgId} targetId={targetId} eventId={eventId} compact />}
|
{eventId && selected.filter((x) => x.kind === "ZEROZERO").map((x) => <ZerozeroGamePicker key={x.id} api={api} orgId={orgId} targetId={x.id} eventId={eventId} compact />)}
|
||||||
{targets.length > 1 && (
|
{targets.length > 1 && (
|
||||||
<select aria-label={t.deliverTo} value={targetId} onChange={(e) => setTargetId(e.target.value)} className="h-6 max-w-[140px] border border-black bg-cell px-1 text-[12px] text-ink">
|
<span className="relative">
|
||||||
{targets.map((x) => (
|
<button
|
||||||
<option key={x.id} value={x.id}>
|
type="button"
|
||||||
{x.name}
|
onClick={() => setPickOpen((o) => !o)}
|
||||||
</option>
|
aria-expanded={pickOpen}
|
||||||
))}
|
aria-label={t.deliverTo}
|
||||||
</select>
|
title={selectedLabel}
|
||||||
|
className="h-6 max-w-[180px] truncate border border-black bg-cell px-2 text-[12px] text-ink hover:bg-cell-on"
|
||||||
|
>
|
||||||
|
{selected.length ? selectedLabel : t.deliverTo}
|
||||||
|
</button>
|
||||||
|
{pickOpen && (
|
||||||
|
<div className="absolute left-0 top-7 z-30 max-h-[60vh] w-[220px] space-y-1 overflow-y-auto border border-black bg-panel p-2 text-[12px] shadow-xl" role="group" aria-label={t.deliverTo}>
|
||||||
|
{targets.map((x) => (
|
||||||
|
<label key={x.id} className="flex items-center gap-2">
|
||||||
|
<input type="checkbox" checked={chosenTargets.includes(x.id)} onChange={() => toggle(x.id)} />
|
||||||
|
<span className="min-w-0 truncate text-ink">{x.name}</span>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
onClick={() => void send()}
|
onClick={() => void send()}
|
||||||
disabled={busy || !photos.length || !targetId}
|
disabled={busy || !photos.length || !selected.length}
|
||||||
title={photos.length ? `${t.sendTo} ${targets.find((x) => x.id === targetId)?.name ?? ""}` : t.selectToSend}
|
title={photos.length ? `${t.sendTo} ${selectedLabel}` : t.selectToSend}
|
||||||
className="h-6 bg-accent px-3 text-[12px] font-semibold text-white hover:bg-accent-strong disabled:opacity-40"
|
className="h-6 bg-accent px-3 text-[12px] font-semibold text-white hover:bg-accent-strong disabled:opacity-40"
|
||||||
>
|
>
|
||||||
{t.sendN(photos.length)}
|
{t.sendN(photos.length)}
|
||||||
@@ -122,8 +177,8 @@ export function SendButton(props: { api: ApiClient; orgId: string; selection: Ph
|
|||||||
<input type="checkbox" checked={bestAgain} onChange={(e) => setBestAgain(e.target.checked)} />
|
<input type="checkbox" checked={bestAgain} onChange={(e) => setBestAgain(e.target.checked)} />
|
||||||
{t.bestAgain}
|
{t.bestAgain}
|
||||||
</label>
|
</label>
|
||||||
<button disabled={busy || !targetId} className="h-7 w-full bg-accent font-semibold text-white disabled:opacity-40">
|
<button disabled={busy || !selected.length} className="h-7 w-full bg-accent font-semibold text-white disabled:opacity-40">
|
||||||
{t.bestSend(target?.name ?? "")}
|
{t.bestSend(selectedLabel)}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -48,6 +48,20 @@ async function slot<T>(fn: () => Promise<T>): Promise<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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<Response> {
|
||||||
|
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
|
* 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.
|
* 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<string | null> {
|
|||||||
if (kept) return URL.createObjectURL(kept);
|
if (kept) return URL.createObjectURL(kept);
|
||||||
try {
|
try {
|
||||||
const blob = await slot(async () => {
|
const blob = await slot(async () => {
|
||||||
const res = await fetch(url);
|
const res = await fetchWithTimeout(url);
|
||||||
if (!res.ok) throw new Error(`http_${res.status}`);
|
if (!res.ok) throw new Error(`http_${res.status}`);
|
||||||
return res.blob();
|
return res.blob();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::sync::atomic::{AtomicU64, Ordering};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::UNIX_EPOCH;
|
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).
|
/// Paths already handed to the web app (so the next scan does not send them twice).
|
||||||
taken: Mutex<HashSet<String>>,
|
taken: Mutex<HashSet<String>>,
|
||||||
last_error: Arc<Mutex<Option<String>>>,
|
last_error: Arc<Mutex<Option<String>>>,
|
||||||
|
/// Bumped on every start/stop so a stopped server's late "shutdown" error can't land on a newer one.
|
||||||
|
epoch: Arc<AtomicU64>,
|
||||||
checks: Mutex<Vec<AddressCheck>>,
|
checks: Mutex<Vec<AddressCheck>>,
|
||||||
firewall: Mutex<Option<String>>,
|
firewall: Mutex<Option<String>>,
|
||||||
}
|
}
|
||||||
@@ -549,9 +552,15 @@ impl FtpState {
|
|||||||
|
|
||||||
*self.last_error.lock().unwrap() = None;
|
*self.last_error.lock().unwrap() = None;
|
||||||
let last_error = self.last_error.clone();
|
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 {
|
tauri::async_runtime::spawn(async move {
|
||||||
if let Err(e) = server.listen(format!("0.0.0.0:{port}")).await {
|
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 });
|
*self.running.lock().unwrap() = Some(Running { stop: stop_tx });
|
||||||
@@ -560,7 +569,11 @@ impl FtpState {
|
|||||||
|
|
||||||
pub fn stop(&self) {
|
pub fn stop(&self) {
|
||||||
if let Some(r) = self.running.lock().unwrap().take() {
|
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(());
|
let _ = r.stop.send(());
|
||||||
|
*self.last_error.lock().unwrap() = None;
|
||||||
}
|
}
|
||||||
self.checks.lock().unwrap().clear();
|
self.checks.lock().unwrap().clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,8 +138,10 @@ describe("vars", () => {
|
|||||||
|
|
||||||
describe("delivery paths", () => {
|
describe("delivery paths", () => {
|
||||||
const vsc = buildVars({
|
const vsc = buildVars({
|
||||||
home: "VSC",
|
home: "Vitória SC",
|
||||||
away: "AAAS",
|
away: "AA Águas Santas",
|
||||||
|
homeShort: "VSC",
|
||||||
|
awayShort: "AAAS",
|
||||||
competition: "Campeonato Betclic",
|
competition: "Campeonato Betclic",
|
||||||
competitionCode: "PO01",
|
competitionCode: "PO01",
|
||||||
startsAt: new Date("2026-09-23T19:00:00Z"),
|
startsAt: new Date("2026-09-23T19:00:00Z"),
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ export function renderFileName(template: string, vars: TemplateVars, originalFil
|
|||||||
/** Example destination rules taken from today's deliveries. */
|
/** Example destination rules taken from today's deliveries. */
|
||||||
export const DESTINATION_EXAMPLES = {
|
export const DESTINATION_EXAMPLES = {
|
||||||
fpa: {
|
fpa: {
|
||||||
folder: "/FPA/Fotos/{season}/Competições Nacionais/{competitionCode} - {competition}/{dateCompact} - {home} x {away}/",
|
folder: "/FPA/Fotos/{season}/Competições Nacionais/{competitionCode} - {competition}/{dateCompact} - {homeShort} x {awayShort}/",
|
||||||
fileName: "PS_{home} x {away}_{n}.jpg",
|
fileName: "PS_{homeShort} x {awayShort}_{n}.jpg",
|
||||||
},
|
},
|
||||||
liga: {
|
liga: {
|
||||||
folder: "/LPBetclic {seasonShort}/Jornada {round}/{matchNumber}. {home} x {away}/",
|
folder: "/LPBetclic {seasonShort}/Jornada {round}/{matchNumber}. {home} x {away}/",
|
||||||
|
|||||||
Reference in new issue
Block a user