feat(F-132): completed feature

This commit is contained in:
chattie
2026-08-21 17:45:12 +02:00
parent 3058c81b31
commit f37333bb56
16 changed files with 368 additions and 14 deletions

View File

@@ -54,7 +54,7 @@ async function readIfFile(filePath: string): Promise<Buffer | null> {
async function findOriginal(filename: string): Promise<{ root: string; buffer: Buffer } | null> {
for (const root of UPLOAD_ROOTS) {
const buffer = await readIfFile(path.join(root, filename));
const buffer = await readIfFile(path.join(/*turbopackIgnore: true*/ root, filename));
if (buffer) return { root, buffer };
}
return null;
@@ -114,7 +114,7 @@ export async function GET(
// Cached thumbnail already on disk?
for (const root of UPLOAD_ROOTS) {
const cached = await readIfFile(path.join(root, sizeSegment, filename));
const cached = await readIfFile(path.join(/*turbopackIgnore: true*/ root, sizeSegment, filename));
if (cached) return imageResponse(cached, filename);
}
@@ -126,9 +126,9 @@ export async function GET(
if (!thumbnail) return imageResponse(original.buffer, filename);
try {
const cacheDir = path.join(original.root, sizeSegment);
const cacheDir = path.join(/*turbopackIgnore: true*/ original.root, sizeSegment);
await mkdir(cacheDir, { recursive: true });
await writeFile(path.join(cacheDir, filename), thumbnail);
await writeFile(path.join(/*turbopackIgnore: true*/ cacheDir, filename), thumbnail);
} catch {
// Serving the thumbnail matters more than caching it.
}