fix nim-lang#19343 (#19344) [backport]

Ensure HttpClient onProgress is called once per second
Ensure that reported speed is accurate

(cherry picked from commit 58656aa5bb)
This commit is contained in:
Zachary Marquez
2022-01-08 03:22:56 -06:00
committed by narimiran
parent 30737b3e7f
commit 2539d7a862

View File

@@ -673,7 +673,7 @@ proc reportProgress(client: HttpClient | AsyncHttpClient,
progress: BiggestInt) {.multisync.} =
client.contentProgress += progress
client.oneSecondProgress += progress
if (getMonoTime() - client.lastProgressReport).inSeconds > 1:
if (getMonoTime() - client.lastProgressReport).inSeconds >= 1:
if not client.onProgressChanged.isNil:
await client.onProgressChanged(client.contentTotal,
client.contentProgress,