Skip to content

Commit

Permalink
Attempts to delete file seperately (SEA-1385).
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrillkuettel committed Jul 10, 2024
1 parent 2fdcb96 commit 578db69
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/privatim/views/consultations.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,18 @@ def delete_consultation_view(
context: Consultation, request: 'IRequest'
) -> 'RenderDataOrRedirect':
session = request.dbsession
from sqlalchemy_file.storage import StorageManager
for file in context.files:
try:
# be extra cautious and delete the file first
path = file.file.path
StorageManager.delete_file(path)
except Exception as e:
log.error(f'StorageManager deleting file: {path}; {e}')

try:
session.delete(context)
session.flush()
except Exception as e:
log.error(f'Error deleting consultation: {e}')

Expand Down

0 comments on commit 578db69

Please sign in to comment.