1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-29 03:20:30 +00:00

Added IntegrityError to catched error

This commit is contained in:
Ozzie Isaacs 2021-01-10 10:23:14 +01:00
parent b7de23e895
commit 4a9b01e93b
2 changed files with 4 additions and 4 deletions

View File

@ -30,7 +30,7 @@ from uuid import uuid4
from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, Response
from flask_babel import gettext as _
from flask_login import current_user, login_required
from sqlalchemy.exc import OperationalError
from sqlalchemy.exc import OperationalError, IntegrityError
from . import constants, logger, isoLanguages, gdriveutils, uploader, helper
from . import config, get_locale, ub, db
@ -570,7 +570,7 @@ def upload_single_file(request, book, book_id):
calibre_db.session.add(db_format)
calibre_db.session.commit()
calibre_db.update_title_sort(config)
except OperationalError as e:
except (OperationalError, IntegrityError) as e:
calibre_db.session.rollback()
log.error('Database error: %s', e)
flash(_(u"Database error: %(error)s.", error=e), category="error")
@ -925,7 +925,7 @@ def upload():
else:
resp = {"location": url_for('web.show_book', book_id=book_id)}
return Response(json.dumps(resp), mimetype='application/json')
except OperationalError as e:
except (OperationalError, IntegrityError) as e:
calibre_db.session.rollback()
log.error("Database error: %s", e)
flash(_(u"Database error: %(error)s.", error=e), category="error")

View File

@ -184,7 +184,7 @@ def toggle_read(book_id):
calibre_db.session.commit()
except (KeyError, AttributeError):
log.error(u"Custom Column No.%d is not exisiting in calibre database", config.config_read_column)
except OperationalError as e:
except (OperationalError, OperationalError) as e:
calibre_db.session.rollback()
log.error(u"Read status could not set: %e", e)