Enable series type custom column

This commit is contained in:
Ozzieisaacs 2022-09-10 17:17:20 +02:00
parent 9fa56a2323
commit 110d283a50

View File

@ -53,7 +53,7 @@ from weakref import WeakSet
log = logger.create() log = logger.create()
cc_exceptions = ['composite', 'series'] cc_exceptions = ['composite']
cc_classes = {} cc_classes = {}
Base = declarative_base() Base = declarative_base()
@ -439,6 +439,7 @@ class CalibreDB:
# This is a WeakSet so that references here don't keep other CalibreDB # This is a WeakSet so that references here don't keep other CalibreDB
# instances alive once they reach the end of their respective scopes # instances alive once they reach the end of their respective scopes
instances = WeakSet() instances = WeakSet()
series = False
def __init__(self, expire_on_commit=True, init=False): def __init__(self, expire_on_commit=True, init=False):
""" Initialize a new CalibreDB session """ Initialize a new CalibreDB session
@ -466,6 +467,7 @@ class CalibreDB:
for row in cc: for row in cc:
if row.datatype not in cc_exceptions: if row.datatype not in cc_exceptions:
if row.datatype == 'series': if row.datatype == 'series':
cls.series = True
dicttable = {'__tablename__': 'books_custom_column_' + str(row.id) + '_link', dicttable = {'__tablename__': 'books_custom_column_' + str(row.id) + '_link',
'id': Column(Integer, primary_key=True), 'id': Column(Integer, primary_key=True),
'book': Column(Integer, ForeignKey('books.id'), 'book': Column(Integer, ForeignKey('books.id'),
@ -982,6 +984,10 @@ class CalibreDB:
Base.metadata.remove(table) Base.metadata.remove(table)
def reconnect_db(self, config, app_db_path): def reconnect_db(self, config, app_db_path):
if self.series:
from . import isoLanguages, web_server
web_server.stop(True)
else:
self.dispose() self.dispose()
self.engine.dispose() self.engine.dispose()
self.setup_db(config.config_calibre_dir, app_db_path) self.setup_db(config.config_calibre_dir, app_db_path)