Fixes #5532 win async write (#5791)

* nimgrab tool bugfix: don't divide by zero
* fixes #5532 (asyncfile write on Windows)
* add a comment about what has been tried instead
This commit is contained in:
Andreas Rumpf
2017-05-14 17:10:39 +02:00
committed by GitHub
parent ec50dab57d
commit 3afd852f54
3 changed files with 28 additions and 5 deletions

View File

@@ -7,7 +7,11 @@ when defined(windows):
proc progress(status: DownloadStatus, progress: uint, total: uint,
message: string) {.procvar, gcsafe.} =
echo "Downloading " & url
echo clamp(int(progress.BiggestInt*100 div total.BiggestInt), 0, 100), "%"
let t = total.BiggestInt
if t != 0:
echo clamp(int(progress.BiggestInt*100 div t), 0, 100), "%"
else:
echo "0%"
downloadToFile(url, file, {optUseCache}, progress)
echo "100%"