From 44fa28fab3ff2f0c019ccce81b18f239437b95df Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Wed, 11 Mar 2026 15:01:41 -0400 Subject: [PATCH] Robust delete: handle filesystem unlink errors in hosted file action --- app/routers/api_v3_actions_hosted_file.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/routers/api_v3_actions_hosted_file.py b/app/routers/api_v3_actions_hosted_file.py index 3f28a78..fbc3dbf 100644 --- a/app/routers/api_v3_actions_hosted_file.py +++ b/app/routers/api_v3_actions_hosted_file.py @@ -433,8 +433,12 @@ async def delete_file_action( if method == 'delete': # Hard delete: Record + Disk if file_exists_on_disk: - pathlib.Path(file_path).unlink() - physical_removed = True + try: + pathlib.Path(file_path).unlink() + physical_removed = True + except OSError as e: + log.error(f"Error unlinking file {file_path}: {e}") + physical_removed = False sql_delete(table_name='hosted_file', record_id=file_id_int) record_removed = True elif method == 'hide':