1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-28 20:39:59 +00:00

Always catch sqlite create_function error

This commit is contained in:
Ozzie Isaacs 2022-04-24 13:15:41 +02:00
parent bc96ff9a39
commit 8421a17a82
2 changed files with 8 additions and 7 deletions

View File

@ -25,6 +25,7 @@ from datetime import datetime
from urllib.parse import quote from urllib.parse import quote
import unidecode import unidecode
from sqlite3 import OperationalError as sqliteOperationalError
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy import Table, Column, ForeignKey, CheckConstraint from sqlalchemy import Table, Column, ForeignKey, CheckConstraint
from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float from sqlalchemy import String, Integer, Boolean, TIMESTAMP, Float
@ -942,7 +943,7 @@ class CalibreDB:
conn = conn or self.session.connection().connection.connection conn = conn or self.session.connection().connection.connection
try: try:
conn.create_function("title_sort", 1, _title_sort) conn.create_function("title_sort", 1, _title_sort)
except OperationalError: except sqliteOperationalError:
pass pass
@classmethod @classmethod

View File

@ -37,7 +37,7 @@ from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, R
from flask_babel import gettext as _ from flask_babel import gettext as _
from flask_login import current_user, login_required from flask_login import current_user, login_required
from sqlalchemy.exc import OperationalError, IntegrityError from sqlalchemy.exc import OperationalError, IntegrityError
from sqlite3 import OperationalError as sqliteOperationalError # from sqlite3 import OperationalError as sqliteOperationalError
from . import constants, logger, isoLanguages, gdriveutils, uploader, helper, kobo_sync_status from . import constants, logger, isoLanguages, gdriveutils, uploader, helper, kobo_sync_status
from . import config, get_locale, ub, db from . import config, get_locale, ub, db
from . import calibre_db from . import calibre_db
@ -757,11 +757,11 @@ def edit_book(book_id):
edit_error = False edit_error = False
# create the function for sorting... # create the function for sorting...
try: #try:
calibre_db.update_title_sort(config) calibre_db.update_title_sort(config)
except sqliteOperationalError as e: #except sqliteOperationalError as e:
log.error_or_exception(e) # log.error_or_exception(e)
calibre_db.session.rollback() # calibre_db.session.rollback()
book = calibre_db.get_filtered_book(book_id, allow_show_archived=True) book = calibre_db.get_filtered_book(book_id, allow_show_archived=True)
# Book not found # Book not found