eta
eta copied to clipboard
[etlas] Display progress bars when downloading
When downloading anything via etlas, we should display a progress bar showing how much of the download has finished.
This should be done for:
- When downloading a new Hackage index for
etlas update
. - When downloading a source package.
- When downloading a binary package or binary executables.
Hey @rahulmutt! In order to add this, I think, we've to add it somewhere here. Is it correct?
Also, can we use something like this to add the progress bar?
Yes that looks right, you'll have to dig deeper and see where the HTTP calls are made and integrate progress bars into it. The library looks great and the license looks good so go ahead and add it if you like.
We can add this function:
showBar :: IO ()
showBar = displayConsoleRegions $ do
pg <- newProgressBar def { pgWidth = 50 }
loop pg
where
loop pg = do
b <- isComplete pg
unless b $ do
threadDelay $ <time taken by etlas>
tick pg
loop pg
If somehow we can get the total time taken to update we can update the time.
How can I get the total time etlas is going to take to update it.
I think we have to call this showBar
here.
Also, is this approach correct?
I think you need to take a look at Distribution.Client.HttpUtils
and maybe swap out to a streaming interface that allows you to keep track of progress. The current code calls out to an external process that performs the HTTP(S) requests such as curl
, powershell
, etc. via the HttpTransport
type. I think you can try replacing that with a streaming http library and see if you can integrate progress into it.