From d0aeb019d8fa9c6fb958f503b1da3d26ff209839 Mon Sep 17 00:00:00 2001 From: Analicia Abernathy Date: Mon, 29 Jul 2024 14:46:15 -0500 Subject: [PATCH 01/12] adding missing translations from merge 772 --- app/translations/{th_TH_incomplete.json => th_TH.json} | 2 ++ 1 file changed, 2 insertions(+) rename app/translations/{th_TH_incomplete.json => th_TH.json} (99%) diff --git a/app/translations/th_TH_incomplete.json b/app/translations/th_TH.json similarity index 99% rename from app/translations/th_TH_incomplete.json rename to app/translations/th_TH.json index 988b241c..1a90a84b 100644 --- a/app/translations/th_TH_incomplete.json +++ b/app/translations/th_TH.json @@ -583,6 +583,8 @@ "labelZipFile": "เลือกไฟล์ซิปของคุณ", "maxMem": "หน่วยความจำสูงสุด", "minMem": "หน่วยความจำขั้นต่ำ", + "noneRoles": "ไม่มีบทบาทที่เลือก", + "noRole": "ไม่พบบทบาทจากพารามิเตอร์การค้นหาปัจจุบัน", "myNewServer": "เซิร์ฟเวอร์ใหม่ของฉัน", "newServer": "สร้างเซิร์ฟเวอร์ใหม่", "quickSettings": "การตั้งค่าด่วน", From bcdc464edfa18c85bf23e98b81f36534a656705d Mon Sep 17 00:00:00 2001 From: Analicia Abernathy Date: Mon, 29 Jul 2024 14:47:53 -0500 Subject: [PATCH 02/12] Update th_TH.json --- app/translations/th_TH.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/translations/th_TH.json b/app/translations/th_TH.json index 1a90a84b..2e447473 100644 --- a/app/translations/th_TH.json +++ b/app/translations/th_TH.json @@ -583,10 +583,10 @@ "labelZipFile": "เลือกไฟล์ซิปของคุณ", "maxMem": "หน่วยความจำสูงสุด", "minMem": "หน่วยความจำขั้นต่ำ", - "noneRoles": "ไม่มีบทบาทที่เลือก", - "noRole": "ไม่พบบทบาทจากพารามิเตอร์การค้นหาปัจจุบัน", "myNewServer": "เซิร์ฟเวอร์ใหม่ของฉัน", "newServer": "สร้างเซิร์ฟเวอร์ใหม่", + "noRole": "ไม่พบบทบาทจากพารามิเตอร์การค้นหาปัจจุบัน", + "noneRoles": "ไม่มีบทบาทที่เลือก", "quickSettings": "การตั้งค่าด่วน", "quickSettingsDescription": "ไม่ต้องกังวล คุณสามารถเปลี่ยนแปลงสิ่งเหล่านี้ได้ในภายหลัง", "resetForm": "รีเซ็ตแบบฟอร์ม", From c92071950304775982f8e4e07130f84cb846de92 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Mon, 29 Jul 2024 21:26:58 +0100 Subject: [PATCH 03/12] Update changelog !781 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f2b0764..fa96061e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ TBD - Show natural language name instead of country code in User Config Lang select list ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/773)) - Add remaining `he_IL`, `th_TH` translations from 4.4.0 Release ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/761)) - Fix `fr_FR` syntax issues ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/780) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/778)) +- Add th_TH translations for [!772](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/772) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/781))

## --- [4.4.0] - 2024/05/11 From 245f4736932bde6546865a34b840381637e9dc2a Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 29 Jul 2024 16:41:25 -0400 Subject: [PATCH 04/12] Remove unused and problematic "dropdown-menu" ident from css --- app/frontend/static/assets/css/crafty.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/frontend/static/assets/css/crafty.css b/app/frontend/static/assets/css/crafty.css index be688657..b765bca6 100644 --- a/app/frontend/static/assets/css/crafty.css +++ b/app/frontend/static/assets/css/crafty.css @@ -278,10 +278,6 @@ div.warnings div.wssError a:hover { } /**************************************************************/ -.dropdown-menu { - max-width: 100%; -} - .hidden-input { margin-left: -40px; } \ No newline at end of file From 37752688836a8ced4e667db54174e51d96c522b9 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Mon, 29 Jul 2024 21:48:27 +0100 Subject: [PATCH 05/12] Update changelog !782 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa96061e..dd2b8ab8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ TBD - Security improvements for general user creations on roles page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/763)) - Security improvements for general user creations on user page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/763)) - Use UTC for tokens_valid_from in user config, to resolve token invalidation on instance TZ change ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/765)) +- Remove unused and problematic "dropdown-menu" ident from [!722](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/772) CSS ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/782)) ### Tweaks - Add info note to default creds file ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/760)) - Remove navigation label from sidebar ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/766)) From 627adcdc95549d37981faa13e8bae0d80de29acc Mon Sep 17 00:00:00 2001 From: Zedifus Date: Mon, 29 Jul 2024 21:56:47 +0100 Subject: [PATCH 06/12] Close changelog 4.4.1 --- CHANGELOG.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd2b8ab8..ef8b70a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,5 @@ # Changelog -## --- [4.4.1] - 2024/TBD -### New features -TBD +## --- [4.4.1] - 2024/07/29 ### Refactor - Backups | Allow multiple backup configurations ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/711)) - UploadAPI | Use Crafty's JWT authentication for file uploads ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/762)) @@ -30,9 +28,9 @@ TBD - Change Role selector in server wizard to be a filter list ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/772)) ### Lang - Show natural language name instead of country code in User Config Lang select list ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/773)) -- Add remaining `he_IL`, `th_TH` translations from 4.4.0 Release ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/761)) +- Add remaining `he_IL`, `th_TH` translations from **4.4.0** Release ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/761) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/763)) - Fix `fr_FR` syntax issues ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/780) | [Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/778)) -- Add th_TH translations for [!772](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/772) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/781)) +- Add `th_TH` translations for [!772](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/772) ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/781))

## --- [4.4.0] - 2024/05/11 From ff9abe4359eb8c40f0d66ed000c2deb1e2a6637b Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 29 Jul 2024 18:02:00 -0400 Subject: [PATCH 07/12] Fix directory moves on backup migration --- app/classes/shared/file_helpers.py | 6 ++---- app/migrations/20240308_multi-backup.py | 10 ++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/classes/shared/file_helpers.py b/app/classes/shared/file_helpers.py index 23bf01dd..4fcd0c21 100644 --- a/app/classes/shared/file_helpers.py +++ b/app/classes/shared/file_helpers.py @@ -183,8 +183,7 @@ class FileHelpers: @staticmethod def move_dir(src_path, dest_path): - FileHelpers.copy_dir(src_path, dest_path) - FileHelpers.del_dirs(src_path) + shutil.move(src_path, dest_path) @staticmethod def move_dir_exist(src_path, dest_path): @@ -193,8 +192,7 @@ class FileHelpers: @staticmethod def move_file(src_path, dest_path): - FileHelpers.copy_file(src_path, dest_path) - FileHelpers.del_file(src_path) + shutil.move(src_path, dest_path) @staticmethod def make_archive(path_to_destination, path_to_zip, comment=""): diff --git a/app/migrations/20240308_multi-backup.py b/app/migrations/20240308_multi-backup.py index db154ec8..bc6dc373 100644 --- a/app/migrations/20240308_multi-backup.py +++ b/app/migrations/20240308_multi-backup.py @@ -175,12 +175,10 @@ def migrate(migrator: Migrator, database, **kwargs): Helpers.ensure_dir_exists( os.path.join(server.backup_path, new_backup.backup_id) ) - for file in os.listdir(server.backup_path): - if not os.path.isdir(os.path.join(os.path.join(server.backup_path, file))): - FileHelpers.move_file( - os.path.join(server.backup_path, file), - os.path.join(server.backup_path, new_backup.backup_id, file), - ) + FileHelpers.move_dir( + os.path.join(server.backup_path), + os.path.join(server.backup_path, new_backup.backup_id), + ) Console.debug("Migrations: Dropping old backup table") # Drop the existing backups table From 44b5f2a8094904a004c9d5b49f42e1a00aaeac48 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 30 Jul 2024 00:49:33 +0100 Subject: [PATCH 08/12] Reopen changelog 4.4.1 --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef8b70a2..d1251076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog -## --- [4.4.1] - 2024/07/29 +## --- [4.4.1] - 2024/TBD + +**-----------------------------------------------------------------------------** + +**Initial release was reverted for patching (See Merge Request: [!784](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/784))** + +**-----------------------------------------------------------------------------** ### Refactor - Backups | Allow multiple backup configurations ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/711)) - UploadAPI | Use Crafty's JWT authentication for file uploads ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/762)) From 4a5875918369ce847b048d036926eb98fc9e3832 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 29 Jul 2024 18:04:01 -0400 Subject: [PATCH 09/12] Add function for removing old malformed backups --- app/migrations/20240308_multi-backup.py | 42 +++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/app/migrations/20240308_multi-backup.py b/app/migrations/20240308_multi-backup.py index bc6dc373..ec46286e 100644 --- a/app/migrations/20240308_multi-backup.py +++ b/app/migrations/20240308_multi-backup.py @@ -13,6 +13,13 @@ from app.classes.shared.file_helpers import FileHelpers logger = logging.getLogger(__name__) +def is_valid_backup(backup, all_servers): + try: + return str(backup.server_id) in all_servers + except (TypeError, peewee.DoesNotExist): + return False + + def migrate(migrator: Migrator, database, **kwargs): """ Write your migrations here. @@ -150,9 +157,17 @@ def migrate(migrator: Migrator, database, **kwargs): migrator.create_table(NewSchedules) migrator.run() - + all_servers = [ + row.server_id for row in Servers.select(Servers.server_id).distinct() + ] + all_backups = Backups.select() + Console.info("Cleaning up orphan backups for all servers") + valid_backups = [ + backup for backup in all_backups if is_valid_backup(backup, all_servers) + ] # Copy data from the existing backups table to the new one - for backup in Backups.select(): + for backup in valid_backups: + Console.info(f"Trying to get server for backup migration {backup.server_id}") # Fetch the related server entry from the Servers table server = Servers.get(Servers.server_id == backup.server_id) Console.info(f"Migrations: Migrating backup for server {server.server_name}") @@ -172,13 +187,28 @@ def migrate(migrator: Migrator, database, **kwargs): default=True, enabled=True, ) + Console.info( + f"New backup table created for {server.server_name} with id {new_backup.backup_id}" + ) Helpers.ensure_dir_exists( os.path.join(server.backup_path, new_backup.backup_id) ) - FileHelpers.move_dir( - os.path.join(server.backup_path), - os.path.join(server.backup_path, new_backup.backup_id), - ) + try: + Console.info( + f"Moving old backups to new backup dir for {server.server_name}" + ) + for file in os.listdir(server.backup_path): + if not os.path.isdir( + os.path.join(os.path.join(server.backup_path, file)) + ): + FileHelpers.move_file( + os.path.join(server.backup_path, file), + os.path.join(server.backup_path, new_backup.backup_id, file), + ) + except FileNotFoundError as why: + logger.error( + f"Could not move backup {file} for {server.server_name} to new location with error {why}" + ) Console.debug("Migrations: Dropping old backup table") # Drop the existing backups table From 9f7f588e85d5f452595c5589a447803ed3ea1925 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 30 Jul 2024 14:30:30 -0400 Subject: [PATCH 10/12] 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 %} From 7b739863b35c656ece660c503000e56062d88c6d Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 6 Aug 2024 19:51:39 +0100 Subject: [PATCH 11/12] Update changelog !785 --- CHANGELOG.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1251076..2fc3f6dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,16 @@ # Changelog -## --- [4.4.1] - 2024/TBD +## --- [4.4.1] - 2024/08/06 + +### Patch Fixes +- Migrations | Fix orphan backup configurations crashing migration operation ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/785)) +- Migrations | Fix missing default configuration if no server backup config exists during the migration ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/785)) +- Migrations | Fix extended runtime on move procedure during migration ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/785)) **-----------------------------------------------------------------------------** -**Initial release was reverted for patching (See Merge Request: [!784](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/784))** +**Initial release was reverted for patching (See Merge Request: [!784](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/784))** *2024/07/28* -**-----------------------------------------------------------------------------** -### Refactor +**-----------------------------------------------------------------------------**### Refactor - Backups | Allow multiple backup configurations ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/711)) - UploadAPI | Use Crafty's JWT authentication for file uploads ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/762)) - UploadAPI | Splice files on the frontend to allow chunked uploads as well as bulk uploads ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/762)) From 7c16737fabd0455e32c0388cb4d24d2f2b343595 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Tue, 6 Aug 2024 14:59:10 -0400 Subject: [PATCH 12/12] Appease sonar return nothing instead of false --- app/classes/shared/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 828aa019..6aec5fc4 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -1385,7 +1385,7 @@ class ServerInstance: ) logger.error(f"Back config does not exist for {self.name}. Update Failed.") self.stats_helper.set_update(False) - return False + return was_started = "-1" # Get default backup configuration backup_config = HelpersManagement.get_default_server_backup(self.server_id) @@ -1442,7 +1442,7 @@ class ServerInstance: "Backup failed for " + self.name + ". canceling update.", ) self.stats_helper.set_update(False) - return False + return # lets download the files if HelperServers.get_server_type_by_id(self.server_id) != "minecraft-bedrock":