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(synology): use Thumbnail API with size xl for originals to avoid HEIC

jubnl1963573db41c
diff --git a/server/src/services/memories/synologyService.ts b/server/src/services/memories/synologyService.ts
index c63e7d2ff..d493b960f 100644
--- a/server/src/services/memories/synologyService.ts
+++ b/server/src/services/memories/synologyService.ts
@@ -637,27 +637,20 @@ export async function streamSynologyAsset(
//size: 'sm' 240px| 'm' 320px| 'xl' 1280px| 'preview' ?
- const resolvedSize = size || 'sm';
- const params = kind === 'thumbnail'
- ? new URLSearchParams({
- api: 'SYNO.Foto.Thumbnail',
- method: 'get',
- version: '2',
- mode: 'download',
- id: parsedId.id,
- type: 'unit',
- size: resolvedSize,
- cache_key: parsedId.cacheKey,
- _sid: sid.data,
- })
- : new URLSearchParams({
- api: 'SYNO.Foto.Download',
- method: 'download',
- version: '2',
- cache_key: parsedId.cacheKey,
- unit_id: `[${parsedId.id}]`,
- _sid: sid.data,
- });
+ // Use Thumbnail API for both thumbnail and original — avoids serving raw HEIC files
+ // (original uses xl size to get a full-resolution JPEG-compatible render)
+ const resolvedSize = kind === 'original' ? 'xl' : (size || 'sm');
+ const params = new URLSearchParams({
+ api: 'SYNO.Foto.Thumbnail',
+ method: 'get',
+ version: '2',
+ mode: 'download',
+ id: parsedId.id,
+ type: 'unit',
+ size: resolvedSize,
+ cache_key: parsedId.cacheKey,
+ _sid: sid.data,
+ });
if (passphrase) params.append('passphrase', passphrase);
const url = _buildSynologyEndpoint(synology_credentials.data.synology_url, params.toString());
diff --git a/server/tests/integration/memories-synology.test.ts b/server/tests/integration/memories-synology.test.ts
index aa18b1335..d58803109 100644
--- a/server/tests/integration/memories-synology.test.ts
+++ b/server/tests/integration/memories-synology.test.ts
@@ -166,16 +166,6 @@ vi.mock('../../src/utils/ssrfGuard', async () => {
});
}
- // Original download
- if (apiName === 'SYNO.Foto.Download') {
- const imageBytes = Buffer.from('fake-synology-original');
- return Promise.resolve({
- ok: true, status: 200,
- headers: { get: (h: string) => h === 'content-type' ? 'image/jpeg' : null },
- body: new ReadableStream({ start(c) { c.enqueue(imageBytes); c.close(); } }),
- });
- }
-
return Promise.reject(new Error(`Unexpected safeFetch call to Synology: ${u}, api=${apiName}`));
}