From 70dfc28574892af355ac19724476f24244586d6c Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 5 Jul 2022 14:45:13 -0400 Subject: [PATCH 1/3] Fix unable to restore backup on external meduim --- app/classes/shared/main_controller.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index ffe8ee0c..c15f3009 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -783,26 +783,16 @@ class Controller: def rename_backup_dir(self, old_server_id, new_server_id, new_uuid): server_data = self.servers.get_server_data_by_id(old_server_id) + server_obj = self.servers.get_server_obj(new_server_id) old_bu_path = server_data["backup_path"] ServerPermsController.backup_role_swap(old_server_id, new_server_id) - if not Helpers.is_os_windows(): - backup_path = Helpers.validate_traversal( - self.helper.backup_path, old_bu_path - ) - if Helpers.is_os_windows(): - backup_path = Helpers.validate_traversal( - Helpers.wtol_path(self.helper.backup_path), - Helpers.wtol_path(old_bu_path), - ) - backup_path = Helpers.wtol_path(str(backup_path)) - backup_path.replace(" ", "^ ") - backup_path = Path(backup_path) + backup_path = old_bu_path + backup_path = Path(backup_path) backup_path_components = list(backup_path.parts) backup_path_components[-1] = new_uuid new_bu_path = pathlib.PurePath(os.path.join(*backup_path_components)) - if os.path.isdir(new_bu_path): - if Helpers.validate_traversal(self.helper.backup_path, new_bu_path): - os.rmdir(new_bu_path) + server_obj.backup_path = new_bu_path + self.servers.update_server(server_obj) backup_path.rename(new_bu_path) def register_server( From ea24215e215e0f2909113d5eff027ca9b2ef9828 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 5 Jul 2022 14:55:17 -0400 Subject: [PATCH 2/3] Remove default backup dir location --- app/classes/shared/main_controller.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index c15f3009..692ca79d 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -792,6 +792,11 @@ class Controller: backup_path_components[-1] = new_uuid new_bu_path = pathlib.PurePath(os.path.join(*backup_path_components)) server_obj.backup_path = new_bu_path + default_backup_dir = os.path.join(self.helper.backup_path, new_uuid) + try: + os.rmdir(default_backup_dir) + except: + logger.error("Could not delete default backup dir") self.servers.update_server(server_obj) backup_path.rename(new_bu_path) From a2c59ebad7f217f861c6650d7b7f64acbc3cdf7b Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 5 Jul 2022 23:20:46 +0100 Subject: [PATCH 3/3] Update changelog !390 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd298edb..16dd566f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### New features None ### Bug fixes -None +- Remove redundant path check on backup restore ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/390)) ### Tweaks None ### Lang