From 5d6ada23a485c0006eb69fa88a2e6c1b094d2a94 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 1 Mar 2022 16:54:06 -0500 Subject: [PATCH] Fix visual file loading order. Fix zip imports where directories were not being copied --- app/classes/minecraft/stats.py | 3 ++- app/classes/shared/helpers.py | 22 ++++++++++++++++++---- app/classes/shared/main_controller.py | 11 +++++++++-- app/classes/web/ajax_handler.py | 22 ++++++++++++++++++---- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/app/classes/minecraft/stats.py b/app/classes/minecraft/stats.py index e5411107..da5b725e 100644 --- a/app/classes/minecraft/stats.py +++ b/app/classes/minecraft/stats.py @@ -314,7 +314,8 @@ class Stats: # get our server object, settings and data dictionaries server_obj = self.controller.get_server_obj(server_id) - server_obj.reload_server_settings() + if server_obj: + server_obj.reload_server_settings() server_settings = self.controller.get_server_settings(server_id) server_data = self.controller.get_server_data(server_id) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 7cedc545..d9877f90 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -652,8 +652,15 @@ class Helpers: @staticmethod def generate_tree(folder, output=""): + dir_list = [] + unsorted_files = [] file_list = os.listdir(folder) - file_list = sorted(file_list, key=str.casefold) + for item in file_list: + if os.path.isdir(os.path.join(folder, item)): + dir_list.append(item) + else: + unsorted_files.append(item) + file_list = sorted(dir_list, key=str.casefold) + sorted(unsorted_files, key=str.casefold) for raw_filename in file_list: filename = html.escape(raw_filename) rel = os.path.join(folder, raw_filename) @@ -673,7 +680,7 @@ class Helpers: else: if filename != "crafty_managed.txt": output += f"""
  • {filename}
  • """ @@ -681,8 +688,15 @@ class Helpers: @staticmethod def generate_dir(folder, output=""): + dir_list = [] + unsorted_files = [] file_list = os.listdir(folder) - file_list = sorted(file_list, key=str.casefold) + for item in file_list: + if os.path.isdir(os.path.join(folder, item)): + dir_list.append(item) + else: + unsorted_files.append(item) + file_list = sorted(dir_list, key=str.casefold) + sorted(unsorted_files, key=str.casefold) output += \ f"""