From 7254ce6c812bc78ce36eeafdeac9dc5bd29ef66b Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 5 Feb 2022 15:11:50 +0100 Subject: [PATCH] Prevent delete of everything if database wasn't really changed --- cps/admin.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index c1931ea4..cfb27783 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -1208,15 +1208,16 @@ def _db_configuration_update_helper(): return _db_configuration_result(_('DB Location is not Valid, Please Enter Correct Path'), gdrive_error) # if db changed -> delete shelfs, delete download books, delete read books, kobo sync... - ub.session.query(ub.Downloads).delete() - ub.session.query(ub.ArchivedBook).delete() - ub.session.query(ub.ReadBook).delete() - ub.session.query(ub.BookShelf).delete() - ub.session.query(ub.Bookmark).delete() - ub.session.query(ub.KoboReadingState).delete() - ub.session.query(ub.KoboStatistics).delete() - ub.session.query(ub.KoboSyncedBooks).delete() - ub.session_commit() + if db_change: + ub.session.query(ub.Downloads).delete() + ub.session.query(ub.ArchivedBook).delete() + ub.session.query(ub.ReadBook).delete() + ub.session.query(ub.BookShelf).delete() + ub.session.query(ub.Bookmark).delete() + ub.session.query(ub.KoboReadingState).delete() + ub.session.query(ub.KoboStatistics).delete() + ub.session.query(ub.KoboSyncedBooks).delete() + ub.session_commit() _config_string(to_save, "config_calibre_dir") calibre_db.update_config(config) if not os.access(os.path.join(config.config_calibre_dir, "metadata.db"), os.W_OK):