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

Ensure HttpClient onProgress is called once per second
Ensure that reported speed is accurate
This commit is contained in:
Zachary Marquez 2022-01-08 03:22:56 -06:00 • committed by GitHub
commit 58656aa5bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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