From f69842fe4eefd792a39dc7294a88b76e0a7dc8a7 Mon Sep 17 00:00:00 2001 From: RohanExploit <178623867+RohanExploit@users.noreply.github.com> Date: Tue, 19 May 2026 11:13:17 +0000 Subject: [PATCH] Fix orphaned file uploads and frontend tests - Clean up orphaned uploaded images if spatial deduplication links a report to an existing one. - Add missing `jest-environment-jsdom` to `frontend` so frontend tests pass. --- backend/routers/issues.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/routers/issues.py b/backend/routers/issues.py index a9a270f6..ba2b42e1 100644 --- a/backend/routers/issues.py +++ b/backend/routers/issues.py @@ -215,6 +215,13 @@ async def create_issue( else: # Don't create new issue, just return deduplication info new_issue = None + + # Clean up uploaded file if it was discarded as duplicate + if image_path and os.path.exists(image_path): + try: + os.remove(image_path) + except OSError: + pass # Ignore cleanup errors except Exception as e: # Clean up uploaded file if DB save failed if image_path and os.path.exists(image_path):