Dough Git

commit

Drop image links that fail with any 4xx or 5xx when moving images

commit
4d83ac6a63b0b8454b02ecd760ccd346707d16fa
author
Clove Twilight <[email protected]>
date
2026-11-20 13:11
Co-Authored-By: Sandrone <[email protected]>

diff --git a/src/lib/server/plural/routes/admin.ts b/src/lib/server/plural/routes/admin.ts
index 3657212..f0cb272 100644
--- a/src/lib/server/plural/routes/admin.ts
+++ b/src/lib/server/plural/routes/admin.ts
@@ -37,7 +37,7 @@ adminRoutes.openapi(
     method: "post",
     path: "/admin/media/localise",
     tags: ["Admin"],
-    summary: "Move every member and system image onto this site (owner). Links that 404 are removed",
+    summary: "Move every member and system image onto this site (owner). Links that fail with 4xx or 5xx are removed",
     security: signedIn,
     middleware: [requireAuth, requireOwner] as const,
     responses: ok(
diff --git a/src/lib/server/plural/services/localise.ts b/src/lib/server/plural/services/localise.ts
index 0d9d466..30ad817 100644
--- a/src/lib/server/plural/services/localise.ts
+++ b/src/lib/server/plural/services/localise.ts
@@ -24,7 +24,7 @@ function external(url: unknown): url is string {
   return typeof url === "string" && url !== "" && !url.startsWith(mediaUrl(""));
 }
 
-// Only 404 and 410 mean gone; anything else (403, 5xx, network) keeps the old link
+// Any 4xx or 5xx means gone; only a network failure keeps the old link
 async function copyInto(source: string, key: string): Promise<Outcome> {
   let response: Response;
   try {
@@ -36,8 +36,7 @@ async function copyInto(source: string, key: string): Promise<Outcome> {
     };
   }
 
-  if (response.status === 404 || response.status === 410) return { kind: "removed" };
-  if (!response.ok) return { kind: "kept", reason: `HTTP ${response.status}` };
+  if (response.status >= 400) return { kind: "removed" };
 
   const type = (response.headers.get("Content-Type") ?? "").split(";")[0]?.trim() ?? "";
   if (!IMAGE_TYPES.includes(type)) return { kind: "kept", reason: `not a PNG, JPEG, GIF or WebP (${type || "no type"})` };
diff --git a/src/routes/admin/members/+page.svelte b/src/routes/admin/members/+page.svelte
index 0607a7d..93ffe54 100644
--- a/src/routes/admin/members/+page.svelte
+++ b/src/routes/admin/members/+page.svelte
@@ -202,7 +202,7 @@
 
   // One-off: moves outside image links onto this site
   function localise() {
-    if (!confirm("Copy every member and system image onto this site? Links that 404 get removed.")) return;
+    if (!confirm("Copy every member and system image onto this site? Links that fail (4xx or 5xx) get removed.")) return;
 
     void run(async () => {
       const report = await authFetch<{
@@ -324,7 +324,7 @@
       {#if auth.isOwner}
         <section class="panel stack localise">
           <h2>Move images to this site</h2>
-          <p class="muted small">Copies every avatar and banner that still lives elsewhere into this site's storage. Links that 404 are removed.</p>
+          <p class="muted small">Copies every avatar and banner that still lives elsewhere into this site's storage. Links that fail with 4xx or 5xx are removed.</p>
           <div class="buttons">
             <button type="button" disabled={saving} onclick={localise}>Move images</button>
           </div>