Skip to content

Commit

Permalink
Fix high-cpu when downloading
Browse files Browse the repository at this point in the history
Closes #1389
  • Loading branch information
tresf committed Mar 23, 2017
1 parent e8f26de commit f1673ee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,19 @@ function dl($url, $to, $cookies, $progress) {
$fs = [io.file]::openwrite($to)
$buffer = new-object byte[] 2048
$totalRead = 0
$sw = [diagnostics.stopwatch]::StartNew()

dl_onProgress $totalRead
while(($read = $s.read($buffer, 0, $buffer.length)) -gt 0) {
$fs.write($buffer, 0, $read)
$totalRead += $read

dl_onProgress $totalRead
if ($sw.elapsedmilliseconds -gt 100) {
$sw.restart()
dl_onProgress $totalRead
}
}
$sw.stop()
dl_onProgress $totalRead
} finally {
if ($progress) {
[console]::CursorVisible = $true
Expand Down

0 comments on commit f1673ee

Please sign in to comment.