eta icon indicating copy to clipboard operation
eta copied to clipboard

[etlas] Display progress bars when downloading

Open rahulmutt opened this issue 7 years ago • 4 comments

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.

rahulmutt avatar Feb 01 '18 06:02 rahulmutt

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?

pranjaltale16 avatar Feb 16 '18 21:02 pranjaltale16

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.

rahulmutt avatar Feb 17 '18 05:02 rahulmutt

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?

pranjaltale16 avatar Feb 17 '18 09:02 pranjaltale16

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.

rahulmutt avatar Feb 17 '18 15:02 rahulmutt