feat(update): add setup fallback action and bump 2.1.2
- add installer asset detection in update service - add 'Download and install (setup)' action in update dialog - bump app version to 2.1.2 and extend update service test
This commit is contained in:
@@ -1 +1 @@
|
||||
APP_VERSION = "2.1.1"
|
||||
APP_VERSION = "2.1.2"
|
||||
|
||||
7
main.py
7
main.py
@@ -407,6 +407,10 @@ class VkChatManager(QMainWindow):
|
||||
)
|
||||
update_now_button = message_box.addButton("Обновить сейчас", QMessageBox.ButtonRole.AcceptRole)
|
||||
download_button = message_box.addButton("Скачать", QMessageBox.ButtonRole.AcceptRole)
|
||||
setup_button = None
|
||||
installer_url = result.get("installer_url")
|
||||
if installer_url:
|
||||
setup_button = message_box.addButton("Скачать и установить (setup)", QMessageBox.ButtonRole.AcceptRole)
|
||||
releases_button = message_box.addButton("Релизы", QMessageBox.ButtonRole.ActionRole)
|
||||
cancel_button = message_box.addButton("Позже", QMessageBox.ButtonRole.RejectRole)
|
||||
message_box.setDefaultButton(update_now_button)
|
||||
@@ -422,6 +426,9 @@ class VkChatManager(QMainWindow):
|
||||
if release_url:
|
||||
QDesktopServices.openUrl(QUrl(release_url))
|
||||
return
|
||||
if setup_button is not None and clicked is setup_button and installer_url:
|
||||
QDesktopServices.openUrl(QUrl(installer_url))
|
||||
return
|
||||
if clicked is download_button and download_url:
|
||||
QDesktopServices.openUrl(QUrl(download_url))
|
||||
elif clicked in (download_button, releases_button) and release_url:
|
||||
|
||||
@@ -71,6 +71,8 @@ def _extract_release_payload(release_data, repository_url, current_version):
|
||||
download_url = ""
|
||||
download_name = ""
|
||||
checksum_url = ""
|
||||
installer_url = ""
|
||||
installer_name = ""
|
||||
for asset in assets:
|
||||
url = asset.get("browser_download_url", "")
|
||||
if url.lower().endswith(".zip"):
|
||||
@@ -81,6 +83,16 @@ def _extract_release_payload(release_data, repository_url, current_version):
|
||||
download_url = assets[0].get("browser_download_url", "")
|
||||
download_name = assets[0].get("name", "")
|
||||
|
||||
for asset in assets:
|
||||
url = asset.get("browser_download_url", "")
|
||||
name = asset.get("name", "")
|
||||
name_lower = name.lower()
|
||||
if installer_url:
|
||||
break
|
||||
if url.lower().endswith(".exe") and ("setup" in name_lower or "installer" in name_lower):
|
||||
installer_url = url
|
||||
installer_name = name
|
||||
|
||||
for asset in assets:
|
||||
name = asset.get("name", "").lower()
|
||||
if not name:
|
||||
@@ -102,6 +114,8 @@ def _extract_release_payload(release_data, repository_url, current_version):
|
||||
"release_url": html_url,
|
||||
"download_url": download_url,
|
||||
"download_name": download_name,
|
||||
"installer_url": installer_url,
|
||||
"installer_name": installer_name,
|
||||
"checksum_url": checksum_url,
|
||||
"has_update": _is_newer_version(latest_version, current_version),
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ class UpdateServiceTests(unittest.TestCase):
|
||||
"assets": [
|
||||
{"name": "notes.txt", "browser_download_url": "https://example.com/notes.txt"},
|
||||
{"name": "AnabasisManager-win64.zip", "browser_download_url": "https://example.com/app.zip"},
|
||||
{"name": "AnabasisManager-setup-1.7.2.exe", "browser_download_url": "https://example.com/setup.exe"},
|
||||
{"name": "AnabasisManager-win64.zip.sha256", "browser_download_url": "https://example.com/app.zip.sha256"},
|
||||
],
|
||||
}
|
||||
@@ -43,6 +44,7 @@ class UpdateServiceTests(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(payload["latest_version"], "1.7.2")
|
||||
self.assertEqual(payload["download_url"], "https://example.com/app.zip")
|
||||
self.assertEqual(payload["installer_url"], "https://example.com/setup.exe")
|
||||
self.assertEqual(payload["checksum_url"], "https://example.com/app.zip.sha256")
|
||||
self.assertTrue(payload["has_update"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user