Fix visual file loading order. Fix zip imports where directories were not being copied

This commit is contained in:
Andrew
2022-03-01 16:54:06 -05:00
parent 10d3afab58
commit 5d6ada23a4
4 changed files with 47 additions and 11 deletions

View File

@ -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: