mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix backup restore
This commit is contained in:
parent
f2cc0e89fb
commit
9520858c22
@ -1,5 +1,6 @@
|
||||
import os
|
||||
import pathlib
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import time
|
||||
import logging
|
||||
@ -513,10 +514,13 @@ class Controller:
|
||||
server_data = self.servers.get_server_data_by_id(old_server_id)
|
||||
old_bu_path = server_data['backup_path']
|
||||
Server_Perms_Controller.backup_role_swap(old_server_id, new_server_id)
|
||||
backup_path = helper.validate_traversal(helper.backup_path, old_bu_path)
|
||||
if not helper.is_os_windows():
|
||||
backup_path = helper.validate_traversal(helper.backup_path, old_bu_path)
|
||||
if helper.is_os_windows():
|
||||
backup_path = helper.wtol_path(backup_path)
|
||||
backup_path = helper.validate_traversal(helper.wtol_path(helper.backup_path), helper.wtol_path(old_bu_path))
|
||||
backup_path = helper.wtol_path(str(backup_path))
|
||||
backup_path.replace(' ', '^ ')
|
||||
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))
|
||||
|
@ -337,19 +337,34 @@ class AjaxHandler(BaseHandler):
|
||||
zip_name = bleach.clean(self.get_argument('zip_file', None))
|
||||
svr_obj = self.controller.servers.get_server_obj(server_id)
|
||||
server_data = self.controller.servers.get_server_data_by_id(server_id)
|
||||
backup_path = svr_obj.backup_path
|
||||
if helper.validate_traversal(backup_path, zip_name):
|
||||
tempDir = helper.unzip_backup_archive(backup_path, zip_name)
|
||||
new_server = self.controller.import_zip_server(svr_obj.server_name,
|
||||
tempDir,
|
||||
server_data['executable'],
|
||||
'1', '2',
|
||||
server_data['server_port'])
|
||||
new_server_id = new_server
|
||||
new_server = self.controller.get_server_data(new_server)
|
||||
self.controller.rename_backup_dir(server_id, new_server_id, new_server['server_uuid'])
|
||||
self.controller.remove_server(server_id, True)
|
||||
self.redirect('/panel/dashboard')
|
||||
if server_data['type'] == 'minecraft-java':
|
||||
backup_path = svr_obj.backup_path
|
||||
if helper.validate_traversal(backup_path, zip_name):
|
||||
tempDir = helper.unzip_backup_archive(backup_path, zip_name)
|
||||
new_server = self.controller.import_zip_server(svr_obj.server_name,
|
||||
tempDir,
|
||||
server_data['executable'],
|
||||
'1', '2',
|
||||
server_data['server_port'])
|
||||
new_server_id = new_server
|
||||
new_server = self.controller.get_server_data(new_server)
|
||||
self.controller.rename_backup_dir(server_id, new_server_id, new_server['server_uuid'])
|
||||
self.controller.remove_server(server_id, True)
|
||||
self.redirect('/panel/dashboard')
|
||||
|
||||
else:
|
||||
backup_path = svr_obj.backup_path
|
||||
if helper.validate_traversal(backup_path, zip_name):
|
||||
tempDir = helper.unzip_backup_archive(backup_path, zip_name)
|
||||
new_server = self.controller.import_bedrock_zip_server(svr_obj.server_name,
|
||||
tempDir,
|
||||
server_data['executable'],
|
||||
server_data['server_port'])
|
||||
new_server_id = new_server
|
||||
new_server = self.controller.get_server_data(new_server)
|
||||
self.controller.rename_backup_dir(server_id, new_server_id, new_server['server_uuid'])
|
||||
self.controller.remove_server(server_id, True)
|
||||
self.redirect('/panel/dashboard')
|
||||
|
||||
elif page == "unzip_server":
|
||||
path = self.get_argument('path', None)
|
||||
|
Loading…
Reference in New Issue
Block a user