forked from Support/sp-hydra-veil-gui
Force sync on database delete
This commit is contained in:
parent
95e0f676df
commit
9cacab4d71
1 changed files with 12 additions and 10 deletions
|
|
@ -9,6 +9,8 @@ from core.models.manage.migrations import migrate_sql
|
||||||
# generic
|
# generic
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# DISPLAY CHOICES AND RECOVERY UI
|
# DISPLAY CHOICES AND RECOVERY UI
|
||||||
|
|
@ -28,7 +30,8 @@ def recovery_dialog(custom_error, db_version_you_have):
|
||||||
if choice == 1:
|
if choice == 1:
|
||||||
if os.path.exists(database_path):
|
if os.path.exists(database_path):
|
||||||
os.remove(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..")
|
logger.info(f"[DB MANAGEMENT] Closing the app gracefully, for them to reboot..")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
@ -54,6 +57,7 @@ if not assets_folder_setup():
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# INITIALIZE DATABASE
|
# INITIALIZE DATABASE
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
lock_file = Path(f"{Constants.HV_DATA_HOME}/deleted_db.lock")
|
||||||
logger.info("[DB MANAGEMENT] Starting DB init..")
|
logger.info("[DB MANAGEMENT] Starting DB init..")
|
||||||
try:
|
try:
|
||||||
# Does the database exist?
|
# Does the database exist?
|
||||||
|
|
@ -130,11 +134,6 @@ if is_compatable:
|
||||||
if not migration.valid:
|
if not migration.valid:
|
||||||
db_version_you_have = 0
|
db_version_you_have = 0
|
||||||
failed_migration(db_version_you_have)
|
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
|
# ASSUME TABLES CREATED
|
||||||
logger.info("[DB MANAGEMENT] Tables successfully made or initialized if pre-existing")
|
logger.info("[DB MANAGEMENT] Tables successfully made or initialized if pre-existing")
|
||||||
|
|
@ -153,12 +152,15 @@ if is_compatable:
|
||||||
force_sync = True
|
force_sync = True
|
||||||
else:
|
else:
|
||||||
logger.info(f"[DB MANAGEMENT] Launcher is now passing it off to launch the main GUI window WITHOUT force sync..")
|
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
|
force_sync = False
|
||||||
|
|
||||||
# make sure we declared it:
|
# if we deleted their DB, we want to force sync,
|
||||||
if 'force_sync' not in globals():
|
if lock_file.exists():
|
||||||
force_sync = False
|
force_sync = True
|
||||||
|
lock_file.unlink() # unlock for next time
|
||||||
|
|
||||||
# Start GUI either way:
|
# Start GUI either way:
|
||||||
logger.info(f"[DB MANAGEMENT] Starting GUI..")
|
logger.info(f"[DB MANAGEMENT] Starting GUI..")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue