diff options
author | Juan Carlos <juancarlospaco@gmail.com> | 2023-05-26 09:37:59 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-26 14:37:59 +0200 |
commit | f2d26f2973098c2f48484fe321cee6db4bc53caf (patch) | |
tree | ddb458fdedd1cb6663a2042a08f5b0ad7fa5e454 /tools/nimgrab.nim | |
parent | b50babd0ae248b1b62f04090f0c88b7803c8818c (diff) | |
download | Nim-f2d26f2973098c2f48484fe321cee6db4bc53caf.tar.gz |
Fix Nimgrab (#21918)
* . * Fix nimgrab client not closing * Fix nimgrab client not closing * Fix nimgrab client not closing
Diffstat (limited to 'tools/nimgrab.nim')
-rw-r--r-- | tools/nimgrab.nim | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tools/nimgrab.nim b/tools/nimgrab.nim index 7e4161faf..c86159739 100644 --- a/tools/nimgrab.nim +++ b/tools/nimgrab.nim @@ -1,13 +1,20 @@ import std/[os, httpclient] proc syncDownload(url, file: string) = - var client = newHttpClient() + let client = newHttpClient() proc onProgressChanged(total, progress, speed: BiggestInt) = - echo "Downloading " & url & " " & $(speed div 1000) & "kb/s" - echo clamp(int(progress*100 div total), 0, 100), "%" + var message = "Downloading " + message.add url + message.add ' ' + message.addInt speed div 1000 + message.add "kb/s\n" + message.add $clamp(int(progress * 100 div total), 0, 100) + message.add '%' + echo message client.onProgressChanged = onProgressChanged client.downloadFile(url, file) + client.close() echo "100%" if os.paramCount() != 2: |