fixes bug 2419

This commit is contained in:
Thore Schillmann 2022-06-01 22:06:28 +02:00
parent 790080f2a0
commit 7f6e88ce5e
3 changed files with 10 additions and 10 deletions

View File

@ -1668,9 +1668,10 @@ def _db_configuration_update_helper():
if db_change or not db_valid or not config.db_configured \ if db_change or not db_valid or not config.db_configured \
or config.config_calibre_dir != to_save["config_calibre_dir"]: or config.config_calibre_dir != to_save["config_calibre_dir"]:
if not calibre_db.setup_db(to_save['config_calibre_dir'], ub.app_DB_path): if not os.path.exists(metadata_db) or not to_save['config_calibre_dir']:
return _db_configuration_result(_('DB Location is not Valid, Please Enter Correct Path'), return _db_configuration_result(_('DB Location is not Valid, Please Enter Correct Path'), gdrive_error)
gdrive_error) else:
calibre_db.setup_db(to_save['config_calibre_dir'], ub.app_DB_path)
config.store_calibre_uuid(calibre_db, db.Library_Id) config.store_calibre_uuid(calibre_db, db.Library_Id)
# if db changed -> delete shelfs, delete download books, delete read books, kobo sync... # if db changed -> delete shelfs, delete download books, delete read books, kobo sync...
if db_change: if db_change:

View File

@ -567,12 +567,12 @@ class CalibreDB:
if not config_calibre_dir: if not config_calibre_dir:
cls.config.invalidate() cls.config.invalidate()
return False return None
dbpath = os.path.join(config_calibre_dir, "metadata.db") dbpath = os.path.join(config_calibre_dir, "metadata.db")
if not os.path.exists(dbpath): if not os.path.exists(dbpath):
cls.config.invalidate() cls.config.invalidate()
return False return None
try: try:
cls.engine = create_engine('sqlite://', cls.engine = create_engine('sqlite://',
@ -588,7 +588,7 @@ class CalibreDB:
# conn.text_factory = lambda b: b.decode(errors = 'ignore') possible fix for #1302 # conn.text_factory = lambda b: b.decode(errors = 'ignore') possible fix for #1302
except Exception as ex: except Exception as ex:
cls.config.invalidate(ex) cls.config.invalidate(ex)
return False return None
cls.config.db_configured = True cls.config.db_configured = True
@ -598,7 +598,7 @@ class CalibreDB:
cls.setup_db_cc_classes(cc) cls.setup_db_cc_classes(cc)
except OperationalError as e: except OperationalError as e:
log.error_or_exception(e) log.error_or_exception(e)
return False return None
cls.session_factory = scoped_session(sessionmaker(autocommit=False, cls.session_factory = scoped_session(sessionmaker(autocommit=False,
autoflush=True, autoflush=True,
@ -607,7 +607,6 @@ class CalibreDB:
inst.init_session() inst.init_session()
cls._init = True cls._init = True
return True
def get_book(self, book_id): def get_book(self, book_id):
return self.session.query(Books).filter(Books.id == book_id).first() return self.session.query(Books).filter(Books.id == book_id).first()