From 9cacab4d7166401cdaa90af18652ad22eb1a7a5c Mon Sep 17 00:00:00 2001 From: SimplifiedPrivacy Date: Thu, 16 Jul 2026 15:56:41 -0400 Subject: [PATCH] Force sync on database delete --- gui/__main__.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gui/__main__.py b/gui/__main__.py index 165f64b..b73ff78 100644 --- a/gui/__main__.py +++ b/gui/__main__.py @@ -9,6 +9,8 @@ from core.models.manage.migrations import migrate_sql # generic import os import sys +from pathlib import Path + # ============================================================================ # DISPLAY CHOICES AND RECOVERY UI @@ -28,7 +30,8 @@ def recovery_dialog(custom_error, db_version_you_have): if choice == 1: if os.path.exists(database_path): os.remove(database_path) - logger.info(f"[DB MANAGEMENT] Deleted the DB file at {database_path}") + logger.info(f"[DB MANAGEMENT] Deleted the DB file at {database_path}. Now putting lock on for forced sync..") + lock_file.touch() logger.info(f"[DB MANAGEMENT] Closing the app gracefully, for them to reboot..") sys.exit() @@ -54,6 +57,7 @@ if not assets_folder_setup(): # ============================================================================ # INITIALIZE DATABASE # ============================================================================ +lock_file = Path(f"{Constants.HV_DATA_HOME}/deleted_db.lock") logger.info("[DB MANAGEMENT] Starting DB init..") try: # Does the database exist? @@ -130,11 +134,6 @@ if is_compatable: if not migration.valid: db_version_you_have = 0 failed_migration(db_version_you_have) - # close_session() - # custom_error = "Could not Migrate the Database version, please delete the database. You will NOT lose profiles, this is the public data." - # from gui.v2.ui.popups.Database_version import show_recovery_dialog - # choice = show_recovery_dialog({"message": custom_error, "db_version": 0, "status": "cant_make"}) - # sys.exit() # ASSUME TABLES CREATED logger.info("[DB MANAGEMENT] Tables successfully made or initialized if pre-existing") @@ -153,12 +152,15 @@ if is_compatable: force_sync = True else: logger.info(f"[DB MANAGEMENT] Launcher is now passing it off to launch the main GUI window WITHOUT force sync..") - if not migration_happened: + if migration_happened: + force_sync = True + else: force_sync = False - # make sure we declared it: - if 'force_sync' not in globals(): - force_sync = False + # if we deleted their DB, we want to force sync, + if lock_file.exists(): + force_sync = True + lock_file.unlink() # unlock for next time # Start GUI either way: logger.info(f"[DB MANAGEMENT] Starting GUI..")