Commit e6e2a9f3 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Add error handling to log creation with files

We've had some bad cases where a log entry is created, but the
file is not saved due to filesystem errors. So we put the file
creation in a try-except block and if it fails, delete the log
message that was just created before re-raising the exception.
parent f2b55e1c
......@@ -231,8 +231,13 @@ def create_log(issuer, comment, event_or_superevent, filename="",
# Create versioned file
if data_file:
version = create_versioned_file(filename, event_or_superevent.datadir,
data_file)
try:
version = create_versioned_file(filename,
event_or_superevent.datadir, data_file)
except Exception as e:
# If creating the file fails, we want to delete the log entry
log.delete()
raise e
# Update file_version
log.file_version = version
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment