fix(editor): rename tmp before unlinking original in 60fps upscale
Review P2: 변환 성공 후 `unlink(input) → rename(tmp)` 순서였는데, unlink 가 성공하고 rename 이 실패하면 원본이 사라진 채 결과물도 없는 상태가 됩니다. 순서를 뒤집어 `rename(tmp → outPath)` 이 먼저 성공한 뒤에만 기존 원본을 지우도록 바꿨습니다. rename 실패 시에는 tmp 만 정리하고 inputName 을 반환해 "실패해도 원본은 그대로" 의도와 일치하게 됩니다. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -101,11 +101,20 @@ export async function upscaleOriginalTo60Fps(
|
||||
console.warn(`[upscale] minterpolate 실패 — 원본 ${inputName} 유지`)
|
||||
return inputName
|
||||
}
|
||||
// 같은 이름으로 덮어쓰는 경우를 대비해 원본을 먼저 지운다.
|
||||
// 안전 순서: 먼저 tmp → outPath rename (성공해야 원본 교체 진행).
|
||||
// rename 이 실패하면 tmp 만 정리하고 원본은 그대로 둔다.
|
||||
try {
|
||||
await fs.rename(tmpPath, outPath)
|
||||
} catch (err) {
|
||||
await fs.unlink(tmpPath).catch(() => undefined)
|
||||
console.warn(`[upscale] rename 실패 — 원본 ${inputName} 유지: ${(err as Error).message}`)
|
||||
return inputName
|
||||
}
|
||||
// rename 후 input 과 out 경로가 다르면 (확장자 변경 등) 기존 원본 제거.
|
||||
// 이 단계 실패는 디스크 점유만 늘리고 동작에는 영향 없으므로 조용히 무시.
|
||||
if (path.resolve(inputPath) !== path.resolve(outPath)) {
|
||||
await fs.unlink(inputPath).catch(() => undefined)
|
||||
}
|
||||
await fs.rename(tmpPath, outPath)
|
||||
return outName
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user