First fix for #2325 (edit book table with readonly database)

This commit is contained in:
Ozzie Isaacs 2022-03-12 10:19:21 +01:00
parent d80297e1a8
commit 547ea93dc9

View File

@ -1152,6 +1152,7 @@ def edit_list_book(param):
vals = request.form.to_dict()
book = calibre_db.get_book(vals['pk'])
# ret = ""
try:
if param == 'series_index':
edit_book_series_index(vals['value'], book)
ret = Response(json.dumps({'success': True, 'newValue': book.series_index}), mimetype='application/json')
@ -1225,7 +1226,7 @@ def edit_list_book(param):
else:
return _("Parameter not found"), 400
book.last_modified = datetime.utcnow()
try:
calibre_db.session.commit()
# revert change for sort if automatic fields link is deactivated
if param == 'title' and vals.get('checkT') == "false":
@ -1233,7 +1234,10 @@ def edit_list_book(param):
calibre_db.session.commit()
except (OperationalError, IntegrityError) as e:
calibre_db.session.rollback()
log.error("Database error: %s", e)
log.error("Database error: {}".format(e))
ret = Response(json.dumps({'success': False,
'msg': 'Database error: {}'.format(e.orig)}),
mimetype='application/json')
return ret