From df04cfa93e8ccbb2d12bd77c5d46a1cc38b30679 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 25 May 2024 20:45:15 +0800 Subject: [PATCH] Fix speed is null --- tasks/download.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/download.ts b/tasks/download.ts index ad11934..c2667ad 100644 --- a/tasks/download.ts +++ b/tasks/download.ts @@ -157,7 +157,7 @@ class DownloadManager { const now = Date.now(); this.#progress.downloaded_bytes += num; d.downloaded = downloaded; - d.speed = num / (now - d.last_updated); + d.speed = now == d.last_updated ? 0 : num / (now - d.last_updated); d.last_updated = now; } this.#sendEvent();