From 2e0ecba686be5d5412287e6c43393c748917e4ea Mon Sep 17 00:00:00 2001 From: Kajitsy Date: Tue, 27 Aug 2024 20:59:45 +0300 Subject: [PATCH] Fix --- emilia.py | 2 +- locales/en_US.json | 3 +-- locales/ru_RU.json | 3 +-- modules/auto_update.py | 39 ++++++++++++++++++++++++++------------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/emilia.py b/emilia.py index 24e763f..3bd434d 100644 --- a/emilia.py +++ b/emilia.py @@ -39,7 +39,7 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) -version = "2.2.4b2" +version = "2.2.4b3" pre = True sample_rate = 48000 diff --git a/locales/en_US.json b/locales/en_US.json index a951545..0043aa3 100644 --- a/locales/en_US.json +++ b/locales/en_US.json @@ -93,8 +93,7 @@ "character_voice_changed": "The character's voice has been added/changed!" }, "AutoUpdate": { - "upgrade_to": "Upgrade to Build", - "emilia_updated": "Emilia updated to Build", + "upgrade_to": "Upgrade to ", "UpdateCompleteTitle": "Update Complete", "UpdateCompleteMessage": "The update has been successfully installed. Please restart the application." }, diff --git a/locales/ru_RU.json b/locales/ru_RU.json index d0ad415..2e4097b 100644 --- a/locales/ru_RU.json +++ b/locales/ru_RU.json @@ -93,8 +93,7 @@ "character_voice_changed": "Голос персонажа был добавлен/изменен!" }, "AutoUpdate": { - "upgrade_to": "Обновление до Build", - "emilia_updated": "Emilia обновлена до Build", + "upgrade_to": "Обновление до ", "UpdateCompleteTitle": "Обновление завершено", "UpdateCompleteMessage": "Обновление успешно установлено. Пожалуйста, перезапустите приложение." }, diff --git a/modules/auto_update.py b/modules/auto_update.py index e5bf3c3..82e64ab 100644 --- a/modules/auto_update.py +++ b/modules/auto_update.py @@ -25,23 +25,36 @@ def check_for_updates(ver, target_filename, pre=False, parent=None): releases = response.json() + latest_release = None + latest_prerelease = None for release in releases: - latest_version = release["tag_name"] - if pre or not release["prerelease"]: - if version.parse(latest_version) > version.parse(ver): - reply = QMessageBox.question( - parent, 'An update is available', - f"{trls.tr('AutoUpdate', 'upgrade_to')} {latest_version}?", - QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No - ) - - if reply == QMessageBox.StandardButton.Yes: - update(release, target_filename, parent) - return + if not latest_release and not release["prerelease"]: + latest_release = release + elif not latest_prerelease and release["prerelease"]: + latest_prerelease = release + + target_release = None + if pre and latest_prerelease: + target_release = latest_prerelease + else: + target_release = latest_release + + if target_release: + latest_version = target_release["tag_name"] + if version.parse(latest_version) > version.parse(ver): + reply = QMessageBox.question( + parent, 'An update is available', + f"{trls.tr('AutoUpdate', 'upgrade_to')} {latest_version}?", + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No + ) + + if reply == QMessageBox.StandardButton.Yes: + update(target_release, target_filename, parent) + return except requests.exceptions.RequestException as e: QMessageBox.warning( - parent, trls.tr('Errors', 'Error'), + parent, trls.tr('Errors', 'Error'), f"{trls.tr('Errors', 'UpdateCheckError')} {e}" ) writeconfig('autoupdate_enable', False)