GUI: Improve config file sanitize step

This commit is contained in:
deajan 2025-02-12 18:30:12 +01:00
parent 4b3bb4bebe
commit 1cc3e4a91f
3 changed files with 14 additions and 6 deletions

View file

@ -63,7 +63,6 @@ sg.TreeData.delete = delete
ENCRYPTED_DATA_PLACEHOLDER = "<{}>".format(_t("config_gui.encrypted_data"))
BAD_KEYS_FOUND_IN_CONFIG = set()
def ask_manager_password(manager_password: str) -> bool:
@ -192,7 +191,9 @@ def config_gui(full_config: dict, config_file: str):
raise ValueError("Bogus object type given")
window.close()
if object_type and object_name:
full_config = update_object_gui(full_config, object_type, object_name, unencrypted=False)
full_config = update_object_gui(
full_config, object_type, object_name, unencrypted=False
)
update_global_gui(full_config, unencrypted=False)
return full_config, object_type, object_name
@ -289,7 +290,7 @@ def config_gui(full_config: dict, config_file: str):
Update gui values depending on their type
This not called directly, but rather from update_object_gui which calls iter_over_config which calls this function
"""
global BAD_KEYS_FOUND_IN_CONFIG
nonlocal BAD_KEYS_FOUND_IN_CONFIG
nonlocal backup_paths_tree
nonlocal tags_tree
@ -629,7 +630,12 @@ def config_gui(full_config: dict, config_file: str):
update_source_layout(source_type)
if BAD_KEYS_FOUND_IN_CONFIG:
if sg.popup_yes_no(_t("config_gui.delete_bad_keys") + f":{BAD_KEYS_FOUND_IN_CONFIG}"):
answer = sg.popup_yes_no(
_t("config_gui.delete_bad_keys")
+ f": {','.join(BAD_KEYS_FOUND_IN_CONFIG)}",
keep_on_top=True,
)
if answer == "Yes":
for key in BAD_KEYS_FOUND_IN_CONFIG:
full_key_path = f"{object_type}.{object_name}.{key}"
logger.info(f"Deleting bogus key {full_key_path}")
@ -2229,6 +2235,8 @@ Google Cloud storage: GOOGLE_PROJECT_ID GOOGLE_APPLICATION_CREDENTIALS\n\
enable_close_attempted_event=True,
)
# Init fresh config objects
BAD_KEYS_FOUND_IN_CONFIG = set()
backup_paths_tree = sg.TreeData()
tags_tree = sg.TreeData()
exclude_patterns_tree = sg.TreeData()

View file

@ -62,7 +62,7 @@ en:
runner_not_configured: Backend not configured properly. Please see logs
no_binary: Cannot find backup backend. Please install restic binary from restic.net
key_error: Key from configuration has no match in GUI
delete_bad_keys: Do you want to delete the bogus keys ? Note that this only affects current object. If key is inherited, you will need to load corresponding group
delete_bad_keys: Do you want to delete the bogus keys ? Note that this only affects current object. If key is inherited, you will need to load corresponding group. Concerned keys in current object
configuration_saved: Configuration saved
cannot_save_configuration: Could not save configuration. See logs for further info

View file

@ -63,7 +63,7 @@ fr:
runner_not_configured: Backend non configuré proprement. Verifier les logs
no_binary: Impossible de trouver le coeur de sauvegarde. Merci d'installer le binaire restic depuis restic.net
key_error: Un entrée de la configuration n'a pas d'équivalent dans l'interface
delete_bad_keys: Souhaitez-vous supprimer les entrées non conformes ? Notez que seul l'objet courant sera affecté. Si l'entrée est un héritage, il faudra charger le groupe correspondant
delete_bad_keys: Souhaitez-vous supprimer les entrées non conformes ? Notez que seul l'objet courant sera affecté. Si l'entrée est un héritage, il faudra charger le groupe correspondant. Entrées concernées dans l'objet courant
configuration_saved: Configuration sauvegardée
cannot_save_configuration: Impossible d'enregistrer la configuration. Veuillez consulter les journaux pour plus de détails