mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-24 18:47:23 +00:00
parent
393869e538
commit
e32b017431
@ -48,6 +48,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
use_unidecode = False
|
use_unidecode = False
|
||||||
|
|
||||||
|
Session = None
|
||||||
|
|
||||||
cc_exceptions = ['datetime', 'comments', 'composite', 'series']
|
cc_exceptions = ['datetime', 'comments', 'composite', 'series']
|
||||||
cc_classes = {}
|
cc_classes = {}
|
||||||
@ -409,6 +410,7 @@ class CalibreDB():
|
|||||||
def setup_db(self, config, app_db_path):
|
def setup_db(self, config, app_db_path):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.dispose()
|
self.dispose()
|
||||||
|
global Session
|
||||||
|
|
||||||
if not config.config_calibre_dir:
|
if not config.config_calibre_dir:
|
||||||
config.invalidate()
|
config.invalidate()
|
||||||
@ -678,6 +680,7 @@ class CalibreDB():
|
|||||||
conn.create_function("title_sort", 1, _title_sort)
|
conn.create_function("title_sort", 1, _title_sort)
|
||||||
|
|
||||||
def dispose(self):
|
def dispose(self):
|
||||||
|
# global session
|
||||||
|
|
||||||
old_session = self.session
|
old_session = self.session
|
||||||
self.session = None
|
self.session = None
|
||||||
|
@ -53,7 +53,7 @@ class TaskConvert(CalibreTask):
|
|||||||
|
|
||||||
def _convert_ebook_format(self):
|
def _convert_ebook_format(self):
|
||||||
error_message = None
|
error_message = None
|
||||||
# local_session = db.Session()
|
local_session = db.Session()
|
||||||
file_path = self.file_path
|
file_path = self.file_path
|
||||||
book_id = self.bookid
|
book_id = self.bookid
|
||||||
format_old_ext = u'.' + self.settings['old_book_format'].lower()
|
format_old_ext = u'.' + self.settings['old_book_format'].lower()
|
||||||
@ -94,10 +94,10 @@ class TaskConvert(CalibreTask):
|
|||||||
book_format=self.settings['new_book_format'].upper(),
|
book_format=self.settings['new_book_format'].upper(),
|
||||||
book=book_id, uncompressed_size=os.path.getsize(file_path + format_new_ext))
|
book=book_id, uncompressed_size=os.path.getsize(file_path + format_new_ext))
|
||||||
try:
|
try:
|
||||||
calibre_db.session.merge(new_format)
|
local_session.merge(new_format)
|
||||||
calibre_db.session.commit()
|
local_session.commit()
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
calibre_db.session.rollback()
|
local_session.rollback()
|
||||||
log.error("Database error: %s", e)
|
log.error("Database error: %s", e)
|
||||||
return
|
return
|
||||||
self.results['path'] = cur_book.path
|
self.results['path'] = cur_book.path
|
||||||
|
Loading…
Reference in New Issue
Block a user