use flush, refresh and rollback instead of intemediate commit statements

This commit is contained in:
Patrick Jentsch 2021-01-28 11:25:02 +01:00
parent 07191b36b2
commit 2b1a74efb8

View File

@ -51,13 +51,13 @@ def service(service):
service_version=form.version.data,
status='preparing', title=form.title.data)
db.session.add(job)
db.session.commit()
db.session.flush()
db.session.refresh(job)
try:
os.makedirs(job.path)
except OSError:
logging.error('Make dir {} led to an OSError!'.format(job.path))
db.session.delete(job)
db.session.commit()
db.session.rollback()
flash('Internal Server Error', 'error')
return make_response(
{'redirect_url': url_for('.service', service=service)}, 500)