From d2787364cd23cb6296ce670d21069a11af440820 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Fri, 6 Jan 2023 11:24:10 +0300 Subject: [PATCH] fixed *.xml files deletion skip when saving data --- app/ui/backup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/ui/backup.py b/app/ui/backup.py index 08615400..9169af43 100644 --- a/app/ui/backup.py +++ b/app/ui/backup.py @@ -245,8 +245,8 @@ def backup_data(path, backup_path, move=True): backup_path = f"{backup_path}{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}{SEP}" os.makedirs(os.path.dirname(backup_path), exist_ok=True) os.makedirs(os.path.dirname(path), exist_ok=True) - # Backup files in data dir(skipping dirs and satellites.xml). - for file in filter(lambda f: f != "satellites.xml" and os.path.isfile(os.path.join(path, f)), os.listdir(path)): + # Backup files in data dir(skipping dirs and *.xml). + for file in filter(lambda f: not f.endswith(".xml") and os.path.isfile(os.path.join(path, f)), os.listdir(path)): src, dst = os.path.join(path, file), backup_path + file shutil.move(src, dst) if move else shutil.copy(src, dst) # Compressing to zip and delete remaining files. @@ -263,8 +263,8 @@ def restore_data(src, dst): def clear_data_path(path): - """ Clearing data at the specified path excluding satellites.xml file """ - for file in filter(lambda f: f != "satellites.xml" and os.path.isfile(os.path.join(path, f)), os.listdir(path)): + """ Clearing data at the specified path excluding *.xml file. """ + for file in filter(lambda f: not f.endswith(".xml") and os.path.isfile(os.path.join(path, f)), os.listdir(path)): os.remove(os.path.join(path, file))