From 7f5e09096a69e8f5af229fb0df20d6320a3bfab8 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Fri, 3 Apr 2026 13:51:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=AC=B8=EC=84=9C=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EC=8B=9C=20processing=5Fqueue=20FK=20=EC=A0=9C=EC=95=BD=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20+=20=EB=B3=80=ED=99=98=EB=B3=B8/preview=20?= =?UTF-8?q?=ED=95=A8=EA=BB=98=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- app/api/documents.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/api/documents.py b/app/api/documents.py index 02af95c..a57cd5c 100644 --- a/app/api/documents.py +++ b/app/api/documents.py @@ -380,10 +380,25 @@ async def delete_document( raise HTTPException(status_code=404, detail="문서를 찾을 수 없습니다") if delete_file: + # 원본 파일 삭제 file_path = Path(settings.nas_mount_path) / doc.file_path if file_path.exists(): file_path.unlink() + # 변환본 삭제 + if doc.original_path: + orig = Path(settings.nas_mount_path) / doc.original_path + if orig.exists(): + orig.unlink() + # preview 캐시 삭제 + preview = Path(settings.nas_mount_path) / "PKM" / ".preview" / f"{doc_id}.pdf" + if preview.exists(): + preview.unlink() + # 관련 processing_queue 먼저 삭제 (FK 제약) + from sqlalchemy import delete as sql_delete + await session.execute( + sql_delete(ProcessingQueue).where(ProcessingQueue.document_id == doc_id) + ) await session.delete(doc) await session.commit()