feat: 优化下载器测速中止条件

This commit is contained in:
DLmaster361
2025-06-06 22:38:37 +08:00
parent 18dfdba15d
commit 1cc242fa51
2 changed files with 15 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ v4.3
作者DLmaster_361
"""
from loguru import logger
import zipfile
import requests
import subprocess
@@ -86,6 +87,7 @@ class DownloadProcess(QThread):
self.download_path = download_path
self.check_times = check_times
@logger.catch
def run(self) -> None:
# 清理可能存在的临时文件
@@ -165,6 +167,7 @@ class ZipExtractProcess(QThread):
self.app_path = app_path
self.download_path = download_path
@logger.catch
def run(self) -> None:
try:
@@ -238,6 +241,7 @@ class DownloadManager(QDialog):
self.download_path = app_path / "DOWNLOAD_TEMP.zip" # 临时下载文件的路径
self.download_process_dict: Dict[str, DownloadProcess] = {}
self.timer_dict: Dict[str, QTimer] = {}
self.if_speed_test_accomplish = False
self.resize(700, 70)
@@ -409,6 +413,15 @@ class DownloadManager(QDialog):
if not self.download_process_dict:
self.download_process_clear.emit()
# 当有速度大于1 MB/s的链接或存在3个即以上链接测速完成时停止其他测速
if not self.if_speed_test_accomplish and (
sum(1 for speed in self.test_speed_result.values() if speed > 0) >= 3
or any(speed > 1 for speed in self.test_speed_result.values())
):
self.if_speed_test_accomplish = True
for timer in self.timer_dict.values():
timer.timeout.emit()
if any(speed == -1 for _, speed in self.test_speed_result.items()):
return None

View File

@@ -6,7 +6,8 @@
"公招喜报模板优化"
],
"程序优化": [
"Mirror 酱链接添加`source`字段,用于标识来源"
"Mirror 酱链接添加`source`字段,用于标识来源",
"优化下载器测速中止条件"
]
},
"4.3.10.1": {