fix: make deletion of single file commit to DB, create tests for file deletion (#8953)

* Added commit to db session

* Changed order

* Deleted flush

* Added test to files
This commit is contained in:
Lucas Oliveira 2025-07-09 12:17:54 -03:00 • committed by GitHub
commit 1362aa1172
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 3 deletions

View file

@ -275,7 +275,6 @@ async def delete_files_batch(
await session.delete(file)
# Delete all files from the database
await session.flush() # Ensures delete is staged
await session.commit() # Commit deletion
except Exception as e:
@ -474,7 +473,7 @@ async def delete_file(
# Delete from the database
await session.delete(file_to_delete)
await session.flush() # Ensures delete is staged
await session.commit()
except HTTPException:
# Re-raise HTTPException to avoid being caught by the generic exception handler
@ -506,7 +505,6 @@ async def delete_all_files(
await session.delete(file)
# Delete all files from the database
await session.flush() # Ensures delete is staged
await session.commit() # Commit deletion
except Exception as e: