perf(build): make standalone image deterministic

This commit is contained in:
2026-08-09 21:34:00 +07:00 Unverified
parent c06b2ef88f
commit 1dc44e0215
10 changed files with 65 additions and 32 deletions
+3 -3
View File
@@ -42,10 +42,10 @@ export async function POST(request: Request) {
const stagingDirectory = `${VIDEO_DIR}/staging/${discordId}`;
filePath = `${stagingDirectory}/${stagedVideoId}-${safeFileName(originalFilename)}`;
await mkdir(stagingDirectory, { recursive: true });
await mkdir(/* turbopackIgnore: true */ stagingDirectory, { recursive: true });
await pipeline(
Readable.fromWeb(request.body as never),
createWriteStream(filePath, { flags: "wx" }),
createWriteStream(/* turbopackIgnore: true */ filePath, { flags: "wx" }),
);
return NextResponse.json({
@@ -55,7 +55,7 @@ export async function POST(request: Request) {
size: contentLength,
});
} catch (error) {
if (filePath) await unlink(filePath).catch(() => undefined);
if (filePath) await unlink(/* turbopackIgnore: true */ filePath).catch(() => undefined);
const message = error instanceof Error ? error.message : "Upload failed.";
const status =
message === "Unauthorized" || message === "Not authenticated" ? 401 : 400;