The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(update): review 修复
XiaoYouChR59214765c62e
diff --git a/android/main.py b/android/main.pyindex e738bc8e..5f96d4ea 100644--- a/android/main.py+++ b/android/main.py@@ -123,7 +123,7 @@ def startApp(application):updateService.changed.connect(onUpdateChanged)checkUpdateAtStartup(updateService)- application.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner))+ application.aboutToQuit.connect(lambda: stopEngine(taskService, browserService, aria2RpcServer, featureService, coroutineRunner, updateService))if __name__ == "__main__":diff --git a/app/services/update_service.py b/app/services/update_service.pyindex 9668ea30..0db7f8f8 100644--- a/app/services/update_service.py+++ b/app/services/update_service.py@@ -13,7 +13,7 @@ from enum import auto, IntEnumfrom pathlib import Pathfrom typing import TYPE_CHECKING-from PySide6.QtCore import QObject, QVersionNumber, Signal+from PySide6.QtCore import QObject, Signalfrom loguru import loggerfrom app.client import buildClient, fetchFile@@ -21,6 +21,7 @@ from app.config.constants import VERSIONfrom app.config.paths import APP_DATA_DIR, executableDirfrom app.platform.filesystem import matchChecksumfrom app.services.pack_loader import PackManifest+from app.update import isNewerif TYPE_CHECKING:from app.services.coroutine_runner import CoroutineRunner@@ -48,12 +49,6 @@ def buildPlatformKey() -> str:return f"{OS_MAP[sys.platform]}-{MACHINE_MAP[platform.machine()]}"-def isNewer(current: str, latest: str) -> bool:- v1 = QVersionNumber.fromString(current.lstrip("vV"))- v2 = QVersionNumber.fromString(latest.lstrip("vV"))- return v2 > v1--def buildAssetUrl(source: str, version: str, assetName: str) -> str:return f"{SOURCES[source]['release']}/v{version}/{assetName}"@@ -265,9 +260,9 @@ class UpdateService(QObject):onProgress=lambda p: self._emit("app", UpdateState.DOWNLOADING, progress=p))if sha and not matchChecksum(archivePath, sha):- archivePath.unlink(missing_ok=True)- self._emit("app", UpdateState.FAILED, error="校验失败")- return+ archivePath.unlink(missing_ok=True)+ self._emit("app", UpdateState.FAILED, error="校验失败")+ returnappDir = executableDir.parent.parent if sys.platform == "darwin" else executableDirnewDir = appDir.parent / f"{appDir.name}_new"@@ -294,9 +289,9 @@ class UpdateService(QObject):expectedSha = packData.get("sha256", "")if expectedSha and not matchChecksum(outputPath, expectedSha):- outputPath.unlink(missing_ok=True)- self._emit(packId, UpdateState.FAILED, error="校验失败")- return+ outputPath.unlink(missing_ok=True)+ self._emit(packId, UpdateState.FAILED, error="校验失败")+ returnself._emit(packId, UpdateState.READY)diff --git a/app/update.py b/app/update.pyindex 3ab31429..3ef9e47b 100644--- a/app/update.py+++ b/app/update.py@@ -5,8 +5,16 @@ import sysfrom dataclasses import dataclassfrom typing import Any+from PySide6.QtCore import QVersionNumber+from app.client import buildClient++def isNewer(current: str, latest: str) -> bool:+ v1 = QVersionNumber.fromString(current.lstrip("vV"))+ v2 = QVersionNumber.fromString(latest.lstrip("vV"))+ return v2 > v1+RELEASE_API = "https://api.github.com/repos/XiaoYouChR/Ghost-Downloader-3/releases/latest"diff --git a/app/view/pages/setting_page.py b/app/view/pages/setting_page.pyindex 9fe6ef24..82bf0dae 100644--- a/app/view/pages/setting_page.py+++ b/app/view/pages/setting_page.py@@ -510,10 +510,8 @@ class SettingPage(ScrollArea):)def _onUpdateChecked(self, release) -> None:- from PySide6.QtCore import QVersionNumber- current = QVersionNumber.fromString(VERSION.lstrip("vV"))- latest = QVersionNumber.fromString(release.version.lstrip("vV"))- if current >= latest:+ from app.update import isNewer+ if not isNewer(VERSION, release.version):InfoBar.success(self.tr("当前已是最新版本"),self.tr("当前版本 {0},最新版本 {1}").format(VERSION, release.version),duration=3000, position=InfoBarPosition.BOTTOM_RIGHT, parent=self.window())