feat(F-132): completed feature
This commit is contained in:
@@ -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.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user