From e4f71f667c896ff7bad8c77ea1853eaf4ab40cd6 Mon Sep 17 00:00:00 2001 From: Chris Barber Date: Tue, 5 Mar 2024 00:50:25 -0600 Subject: [PATCH] Copy and unlink instead of rename --- src/app/api/cla/sign/route.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/api/cla/sign/route.ts b/src/app/api/cla/sign/route.ts index 4e99f23..2c616f4 100644 --- a/src/app/api/cla/sign/route.ts +++ b/src/app/api/cla/sign/route.ts @@ -3,7 +3,7 @@ import { CLA_VERISON } from '@/lib/cla-constants'; import { claDir, createPDF, CreatePDFData } from '@/lib/cla'; import { join } from 'node:path'; import { existsSync } from 'node:fs'; -import { rename, unlink, writeFile } from 'node:fs/promises'; +import { copyFile, unlink, writeFile } from 'node:fs/promises'; import { getServerSession } from 'next-auth/next'; import type { ExtendedProfile } from '@/lib/auth'; import { tmpdir } from 'node:os'; @@ -57,7 +57,8 @@ export async function POST(req: Request) { } const pdfFile = await createPDF(data); - await rename(pdfFile, destPdf); + await copyFile(pdfFile, destPdf); + await unlink(pdfFile); const claInfo = { username: data.githubUsername,