fix:이력 삭제 시 로컬 영상 파일도 함께 삭제

- DB 레코드만 삭제하던 것을 storage/app/video_gen/{id}/ 디렉토리도 삭제
- 클립, 나레이션, BGM, 최종 영상 등 모든 작업 파일 정리

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-15 11:04:58 +09:00
parent 5985b88398
commit 5e4a9c9291

View File

@@ -231,9 +231,27 @@ public function destroy(Request $request): JsonResponse
'ids.*' => 'integer',
]);
$deleted = VideoGeneration::where('user_id', auth()->id())
$videos = VideoGeneration::where('user_id', auth()->id())
->whereIn('id', $request->input('ids'))
->delete();
->get();
$deleted = 0;
foreach ($videos as $video) {
// 로컬 작업 디렉토리 삭제 (클립, 나레이션, 최종 영상 등)
$workDir = storage_path("app/video_gen/{$video->id}");
if (is_dir($workDir)) {
$files = glob("{$workDir}/*");
foreach ($files as $file) {
if (is_file($file)) {
@unlink($file);
}
}
@rmdir($workDir);
}
$video->delete();
$deleted++;
}
return response()->json([
'success' => true,