From 296a5a46deca37c91ebfb94fc9ecf2ef94f56a25 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 7 Sep 2022 16:01:42 -0400 Subject: [PATCH 1/4] Add comments. Debug logging --- app/classes/shared/file_helpers.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/classes/shared/file_helpers.py b/app/classes/shared/file_helpers.py index 28edbef7..f4493f4c 100644 --- a/app/classes/shared/file_helpers.py +++ b/app/classes/shared/file_helpers.py @@ -227,17 +227,21 @@ class FileHelpers: ) # comments over 65535 bytes will be truncated for root, dirs, files in os.walk(path_to_zip, topdown=True): for l_dir in dirs: + # make all paths in exclusions a unix style slash to match directories. if str(os.path.join(root, l_dir)).replace("\\", "/") in ex_replace: dirs.remove(l_dir) ziproot = path_to_zip + # iterate through list of files for file in files: + # check if file/dir is in exclusions list. Only proceed if not exluded. if ( str(os.path.join(root, file)).replace("\\", "/") not in ex_replace and file != "crafty.sqlite" ): try: - logger.info(f"backing up: {os.path.join(root, file)}") + logger.debug(f"backing up: {os.path.join(root, file)}") + # add trailing slash to zip root dir if not windows. if os.name == "nt": zip_file.write( os.path.join(root, file), @@ -254,12 +258,20 @@ class FileHelpers: f"Error backing up: {os.path.join(root, file)}!" f" - Error was: {e}" ) + # debug logging for exlusions list + else: + logger.debug(f"Found {file} in exclusion list. Skipping...") + + # add current file bytes to total bytes. total_bytes += os.path.getsize(os.path.join(root, file)) + # calcualte percentage based off total size and current archive size percent = round((total_bytes / dir_bytes) * 100, 2) + # package results results = { "percent": percent, "total_files": self.helper.human_readable_file_size(dir_bytes), } + # send status results to page. self.helper.websocket_helper.broadcast_page_params( "/panel/server_detail", {"id": str(server_id)}, From d45e32013be91ccf151195b26e713b509d5a8447 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 7 Sep 2022 16:51:41 -0400 Subject: [PATCH 2/4] Fix backup exclusion issue --- app/classes/shared/file_helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/shared/file_helpers.py b/app/classes/shared/file_helpers.py index f4493f4c..e239cd5a 100644 --- a/app/classes/shared/file_helpers.py +++ b/app/classes/shared/file_helpers.py @@ -226,7 +226,7 @@ class FileHelpers: comment, "utf-8" ) # comments over 65535 bytes will be truncated for root, dirs, files in os.walk(path_to_zip, topdown=True): - for l_dir in dirs: + for l_dir in dirs[:]: # make all paths in exclusions a unix style slash to match directories. if str(os.path.join(root, l_dir)).replace("\\", "/") in ex_replace: dirs.remove(l_dir) From 6a6376ea8a6fcab8e9a593304f3fed600a16c494 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 7 Sep 2022 16:52:27 -0400 Subject: [PATCH 3/4] appease the linter --- app/classes/shared/file_helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/classes/shared/file_helpers.py b/app/classes/shared/file_helpers.py index e239cd5a..82b5a560 100644 --- a/app/classes/shared/file_helpers.py +++ b/app/classes/shared/file_helpers.py @@ -227,13 +227,15 @@ class FileHelpers: ) # comments over 65535 bytes will be truncated for root, dirs, files in os.walk(path_to_zip, topdown=True): for l_dir in dirs[:]: - # make all paths in exclusions a unix style slash to match directories. + # make all paths in exclusions a unix style slash + # to match directories. if str(os.path.join(root, l_dir)).replace("\\", "/") in ex_replace: dirs.remove(l_dir) ziproot = path_to_zip # iterate through list of files for file in files: - # check if file/dir is in exclusions list. Only proceed if not exluded. + # check if file/dir is in exclusions list. + # Only proceed if not exluded. if ( str(os.path.join(root, file)).replace("\\", "/") not in ex_replace From 8ce36b5cc8261ff88a75cb97a1484111efb20ee3 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Mon, 19 Sep 2022 21:42:48 +0100 Subject: [PATCH 4/4] Update changelog !453 --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc91683..5d83a0d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,9 @@ ### New features TBD ### Bug fixes -- Fixed bug where trying to reconfigure unloaded server would stack [Commit](https://gitlab.com/crafty-controller/crafty-4/-/commit/1b2fef06fb3b02b76c9506caf7e07e932df95fab) -- Fixes traceback error when a user click the roles config tab while already on the roles config page; **this is for new role creation only**([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/452)) +- Fix bug where trying to reconfigure unloaded server would stack ([Commit](https://gitlab.com/crafty-controller/crafty-4/-/commit/1b2fef06fb3b02b76c9506caf7e07e932df95fab)) +- Fix traceback error when a user click the roles config tab while already on the roles config page; **this is for new role creation only** ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/452)) +- Fix logic issue when removing items from backup exclusions ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/453)) ### Tweaks TBD ### Lang