From 9f7f588e85d5f452595c5589a447803ed3ea1925 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 30 Jul 2024 14:30:30 -0400 Subject: [PATCH] Tweak default backup configs to account for bad clone in 4.2.x --- app/classes/models/management.py | 2 ++ app/classes/shared/server.py | 14 ++++++++++++++ app/frontend/templates/panel/server_backup.html | 3 +-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/classes/models/management.py b/app/classes/models/management.py index 1a3e4a11..b6be14b5 100644 --- a/app/classes/models/management.py +++ b/app/classes/models/management.py @@ -400,6 +400,8 @@ class HelpersManagement: if "excluded_dirs" in conf: dirs_to_exclude = ",".join(conf["excluded_dirs"]) conf["excluded_dirs"] = dirs_to_exclude + if len(self.get_backups_by_server(conf["server_id"], True)) <= 0: + conf["default"] = True backup = Backups.create(**conf) logger.debug("Creating new backup record.") return backup.backup_id diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index ab8ca54a..828aa019 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -1373,6 +1373,19 @@ class ServerInstance: def threaded_jar_update(self): server_users = PermissionsServers.get_server_user_list(self.server_id) + # check to make sure a backup config actually exists before starting the update + if len(self.management_helper.get_backups_by_server(self.server_id, True)) <= 0: + for user in server_users: + WebSocketManager().broadcast_user( + user, + "notification", + "Backup config does not exist for " + + self.name + + ". canceling update.", + ) + logger.error(f"Back config does not exist for {self.name}. Update Failed.") + self.stats_helper.set_update(False) + return False was_started = "-1" # Get default backup configuration backup_config = HelpersManagement.get_default_server_backup(self.server_id) @@ -1428,6 +1441,7 @@ class ServerInstance: "notification", "Backup failed for " + self.name + ". canceling update.", ) + self.stats_helper.set_update(False) return False # lets download the files diff --git a/app/frontend/templates/panel/server_backup.html b/app/frontend/templates/panel/server_backup.html index 86cd9415..73fde1cc 100644 --- a/app/frontend/templates/panel/server_backup.html +++ b/app/frontend/templates/panel/server_backup.html @@ -58,8 +58,7 @@
{% if len(data['backups']) == 0 %}
- {{ translate('serverBackups', 'no-backup', data['lang']) }} {{ - translate('serverBackups', 'newBackup',data['lang']) }}. + {{ translate('serverBackups', 'no-backup', data['lang']) }}.
{% end %} {% if len(data['backups']) > 0 %}