fix: commit template upload atomically
This commit is contained in:
@@ -34,8 +34,9 @@ def upload_template(
|
||||
try:
|
||||
stored_path, content = store_template_file(file)
|
||||
blocks = parse_document(content)
|
||||
template = create_template_record(db, name=name, file_path=stored_path, type=type)
|
||||
save_template_blocks(db, template.id, blocks)
|
||||
template = create_template_record(db, name=name, file_path=stored_path, type=type, commit=False)
|
||||
save_template_blocks(db, template.id, blocks, commit=False)
|
||||
db.commit()
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user