summaryrefslogtreecommitdiff
path: root/lib/bidding/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bidding/service.ts')
-rw-r--r--lib/bidding/service.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/bidding/service.ts b/lib/bidding/service.ts
index ed20ad0c..840173c2 100644
--- a/lib/bidding/service.ts
+++ b/lib/bidding/service.ts
@@ -3255,20 +3255,23 @@ export async function increaseRoundOrRebid(biddingId: number, userId: string | u
eq(biddingDocuments.documentType, 'company_proposal')
)
))
-
+ console.log('existingDocuments', existingDocuments)
if (existingDocuments.length > 0) {
for (const doc of existingDocuments) {
try {
// 기존 파일 경로 확인 및 Buffer로 읽기
const { readFile, access, constants } = await import('fs/promises')
- const { join } = await import('path')
+ const path = await import('path')
// 파일 경로 정규화
- const oldFilePath = doc.filePath.startsWith('/uploads/')
- ? join(process.cwd(), 'public', doc.filePath)
- : doc.filePath.startsWith('/')
- ? join(process.cwd(), 'public', doc.filePath)
- : doc.filePath
+ // 1) 절대 경로면 그대로 사용
+ // 2) /api/files/... 처럼 public 하위 상대 경로면 cwd/public 기준으로 변환
+ // 3) 그 외 문자열은 그대로 시도 (기존 저장 경로)
+ let oldFilePath = doc.filePath
+
+ if (!path.isAbsolute(oldFilePath)) {
+ oldFilePath = path.join(process.cwd(), 'public', oldFilePath.replace(/^\/+/, ''))
+ }
// 파일 존재 여부 확인
try {