From 110d283a50bd56cdccbccf4b4b9c90a4051255be Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 10 Sep 2022 17:17:20 +0200 Subject: [PATCH] Enable series type custom column --- cps/db.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cps/db.py b/cps/db.py index d1c5ec71..9136675a 100644 --- a/cps/db.py +++ b/cps/db.py @@ -53,7 +53,7 @@ from weakref import WeakSet log = logger.create() -cc_exceptions = ['composite', 'series'] +cc_exceptions = ['composite'] cc_classes = {} Base = declarative_base() @@ -439,6 +439,7 @@ class 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 = WeakSet() + series = False def __init__(self, expire_on_commit=True, init=False): """ Initialize a new CalibreDB session @@ -466,6 +467,7 @@ class CalibreDB: for row in cc: if row.datatype not in cc_exceptions: if row.datatype == 'series': + cls.series = True dicttable = {'__tablename__': 'books_custom_column_' + str(row.id) + '_link', 'id': Column(Integer, primary_key=True), 'book': Column(Integer, ForeignKey('books.id'), @@ -982,10 +984,14 @@ class CalibreDB: Base.metadata.remove(table) def reconnect_db(self, config, app_db_path): - self.dispose() - self.engine.dispose() - self.setup_db(config.config_calibre_dir, app_db_path) - self.update_config(config) + if self.series: + from . import isoLanguages, web_server + web_server.stop(True) + else: + self.dispose() + self.engine.dispose() + self.setup_db(config.config_calibre_dir, app_db_path) + self.update_config(config) def lcase(s):