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""""""\
@@ -704,7 +718,7 @@ class Helpers:
else:
if filename != "crafty_managed.txt":
output += f"""- {filename}
"""
diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py
index f4521cb9..3f87b77b 100644
--- a/app/classes/shared/main_controller.py
+++ b/app/classes/shared/main_controller.py
@@ -374,7 +374,10 @@ class Controller:
if str(item) == 'server.properties':
has_properties = True
try:
- file_helper.move_file(os.path.join(tempDir, item), os.path.join(new_server_dir, item))
+ if not os.path.isdir(os.path.join(tempDir, item)):
+ file_helper.move_file(os.path.join(tempDir, item), os.path.join(new_server_dir, item))
+ else:
+ file_helper.move_dir(os.path.join(tempDir, item), os.path.join(new_server_dir, item))
except Exception as ex:
logger.error(f'ERROR IN ZIP IMPORT: {ex}')
if not has_properties:
@@ -457,12 +460,16 @@ class Controller:
helper.ensure_dir_exists(new_server_dir)
helper.ensure_dir_exists(backup_path)
has_properties = False
+ print(os.listdir(tempDir))
#extracts archive to temp directory
for item in os.listdir(tempDir):
if str(item) == 'server.properties':
has_properties = True
try:
- file_helper.move_file(os.path.join(tempDir, item), os.path.join(new_server_dir, item))
+ if not os.path.isdir(os.path.join(tempDir, item)):
+ file_helper.move_file(os.path.join(tempDir, item), os.path.join(new_server_dir, item))
+ else:
+ file_helper.move_dir(os.path.join(tempDir, item), os.path.join(new_server_dir, item))
except Exception as ex:
logger.error(f'ERROR IN ZIP IMPORT: {ex}')
if not has_properties:
diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py
index df3ecdbd..d21f8177 100644
--- a/app/classes/web/ajax_handler.py
+++ b/app/classes/web/ajax_handler.py
@@ -108,8 +108,15 @@ class AjaxHandler(BaseHandler):
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""""""\
@@ -133,7 +140,7 @@ class AjaxHandler(BaseHandler):
else:
output += f"""-
@@ -155,7 +162,7 @@ class AjaxHandler(BaseHandler):
else:
output += f"""
-
@@ -169,8 +176,15 @@ class AjaxHandler(BaseHandler):
folder = self.get_argument('path', None)
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"""