From e7823e27072b318eb2bbd607ca014e114b163620 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 4 Feb 2015 15:06:07 -0400 Subject: [PATCH] Make use of SDK ProgressState enhancement to simplify os download --- lib/actions/os.coffee | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/actions/os.coffee b/lib/actions/os.coffee index b38d2c10..7364e0c9 100644 --- a/lib/actions/os.coffee +++ b/lib/actions/os.coffee @@ -79,23 +79,9 @@ exports.download = console.info("Destination file: #{outputFile}\n") bar = new visuals.widgets.Progress('Downloading Device OS') - time = new Date().getTime() - received = 0 resin.models.os.download osParams, outputFile, callback, (state) -> - return if options.quiet or not state? - - newTime = new Date().getTime() - timeDelta = newTime - time - receivedDelta = state.received - received - - remaining = state.total - state.received - remainingTicks = remaining / receivedDelta - - eta = Math.floor(remainingTicks * timeDelta) - - console.log(bar.tick(state.percent, eta)) - time = newTime + console.log(bar.tick(state.percentage, state.eta)) ], (error) -> return done(error) if error?