Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix: catch sharp errors in ensureLocalThumbnail and fall back to original

jubnled7e2badcae6
diff --git a/server/src/services/memories/thumbnailService.ts b/server/src/services/memories/thumbnailService.ts
index 9a5d22784..765f5f953 100644
--- a/server/src/services/memories/thumbnailService.ts
+++ b/server/src/services/memories/thumbnailService.ts
@@ -27,14 +27,17 @@ export async function ensureLocalThumbnail(
const meta = await sharp(thumbAbs).metadata()
return { thumbnailRelPath: thumbRel, width: meta.width ?? 0, height: meta.height ?? 0 }
}
- } catch { /* regenerate */ }
- await fs.mkdir(path.dirname(thumbAbs), { recursive: true })
- await sharp(originalAbs)
- .rotate()
- .resize({ width: THUMB_MAX, height: THUMB_MAX, fit: 'inside', withoutEnlargement: true })
- .webp({ quality: THUMB_QUALITY })
- .toFile(thumbAbs)
- const meta = await sharp(thumbAbs).metadata()
- return { thumbnailRelPath: thumbRel, width: meta.width ?? 0, height: meta.height ?? 0 }
+ await fs.mkdir(path.dirname(thumbAbs), { recursive: true })
+ await sharp(originalAbs)
+ .rotate()
+ .resize({ width: THUMB_MAX, height: THUMB_MAX, fit: 'inside', withoutEnlargement: true })
+ .webp({ quality: THUMB_QUALITY })
+ .toFile(thumbAbs)
+ const meta = await sharp(thumbAbs).metadata()
+ return { thumbnailRelPath: thumbRel, width: meta.width ?? 0, height: meta.height ?? 0 }
+ } catch {
+ // Unsupported format, corrupt file, etc. — fall back to original in caller.
+ return null
+ }
}