From ea1309eb752bbf2531f6cc00384f6810896afd58 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 20 May 2023 13:50:46 +1200 Subject: [PATCH] preview: support skipping over single missing images inside large albums --- preview.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/preview.go b/preview.go index ba9f76f..f10fe79 100644 --- a/preview.go +++ b/preview.go @@ -109,8 +109,27 @@ html, body { m, err := this.Metadata(fileID) if err != nil { if os.IsNotExist(err) { - http.Error(w, "Not found", 404) - return + + // If this is just one image out of many, show a 404 box and continue to show the other entries + // But if this is only a single image requested, abandon the whole pageload + + if len(fileIDs) == 1 { + http.Error(w, "Not found", 404) + return + } + + tmpl += ` +
+
+ +
+
+ Requested ID ` + html.EscapeString(fileID) + ` not found in storage (404) +
+
+ ` + + continue } log.Println(err.Error())