fix: 无下载任务时速度显示不归零问题

当所有任务处于跳过状态时,update_download_status 不被调用,
导致 _total_download_speed 保留上一次的旧值一直显示。
通过检查 _last_download_time,超过 2 秒无新数据则返回 0。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
yuming
2026-05-09 11:34:35 +08:00
parent 3c1f8e4c5a
commit 49fb1bd55a
+3
View File
@@ -59,6 +59,9 @@ def get_download_result() -> dict:
def get_total_download_speed() -> int: def get_total_download_speed() -> int:
"""get total download speed""" """get total download speed"""
# 超过 2 秒没有新数据,视为速度为 0(防止旧速度值残留显示)
if time.time() - _last_download_time > 2.0:
return 0
return _total_download_speed return _total_download_speed