Robust delete: handle filesystem unlink errors in hosted file action

This commit is contained in:
Scott Idem
2026-03-11 15:01:41 -04:00
parent a20c436013
commit 44fa28fab3

View File

@@ -433,8 +433,12 @@ async def delete_file_action(
if method == 'delete': if method == 'delete':
# Hard delete: Record + Disk # Hard delete: Record + Disk
if file_exists_on_disk: if file_exists_on_disk:
pathlib.Path(file_path).unlink() try:
physical_removed = True 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) sql_delete(table_name='hosted_file', record_id=file_id_int)
record_removed = True record_removed = True
elif method == 'hide': elif method == 'hide':