mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fixed bug where update would not happen once server was shut down if server was running when button was pressed.
This commit is contained in:
parent
a3be2cd2e2
commit
c48fa435fe
@ -348,33 +348,33 @@ class Server:
|
|||||||
if self.check_running():
|
if self.check_running():
|
||||||
logger.info("Server with PID %s is running. Sending shutdown command", self.PID)
|
logger.info("Server with PID %s is running. Sending shutdown command", self.PID)
|
||||||
self.stop_threaded_server()
|
self.stop_threaded_server()
|
||||||
|
|
||||||
|
backup_dir = os.path.join(self.settings['path'], 'crafty_executable_backups')
|
||||||
|
#checks if backup directory already exists
|
||||||
|
if os.path.isdir(backup_dir):
|
||||||
|
backup_executable = os.path.join(backup_dir, 'old_server.jar')
|
||||||
else:
|
else:
|
||||||
backup_dir = os.path.join(self.settings['path'], 'crafty_executable_backups')
|
logger.info("Executable backup directory not found for Server: {}}. Creating one.", self.name)
|
||||||
#checks if backup directory already exists
|
os.mkdir(backup_dir)
|
||||||
if os.path.isdir(backup_dir):
|
backup_executable = os.path.join(backup_dir, 'old_server.jar')
|
||||||
backup_executable = os.path.join(backup_dir, 'old_server.jar')
|
|
||||||
|
if os.path.isfile(backup_executable):
|
||||||
|
#removes old backup
|
||||||
|
logger.info("Old backup found for server: {}. Removing...", self.name)
|
||||||
|
os.remove(backup_executable)
|
||||||
|
logger.info("Old backup removed for server: {}.", self.name)
|
||||||
else:
|
else:
|
||||||
logger.info("Executable backup directory not found for Server: {}}. Creating one.", self.name)
|
logger.info("No old backups found for server: {}", self.name)
|
||||||
os.mkdir(backup_dir)
|
|
||||||
backup_executable = os.path.join(backup_dir, 'old_server.jar')
|
|
||||||
|
|
||||||
if os.path.isfile(backup_executable):
|
current_executable = os.path.join(self.settings['path'], self.settings['executable'])
|
||||||
#removes old backup
|
|
||||||
logger.info("Old backup found for server: {}. Removing...", self.name)
|
|
||||||
os.remove(backup_executable)
|
|
||||||
logger.info("Old backup removed for server: {}.", self.name)
|
|
||||||
else:
|
|
||||||
logger.info("No old backups found for server: {}", self.name)
|
|
||||||
|
|
||||||
current_executable = os.path.join(self.settings['path'], self.settings['executable'])
|
#copies to backup dir
|
||||||
|
helper.copy_files(current_executable, backup_executable)
|
||||||
|
|
||||||
#copies to backup dir
|
#boolean returns true for false for success
|
||||||
helper.copy_files(current_executable, backup_executable)
|
downloaded = helper.download_file(self.settings['executable_update_url'], current_executable)
|
||||||
|
|
||||||
#boolean returns true for false for success
|
if downloaded:
|
||||||
downloaded = helper.download_file(self.settings['executable_update_url'], current_executable)
|
logger.info("Executable updated successfully.")
|
||||||
|
else:
|
||||||
if downloaded:
|
logger.error("Executable download failed.")
|
||||||
logger.info("Executable updated successfully.")
|
|
||||||
else:
|
|
||||||
logger.error("Executable download failed.")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user