summaryrefslogtreecommitdiff
path: root/Command/TransferInfo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-28 17:03:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-28 17:04:37 -0400
commit23bfeef5d168666d17343d5484974b7b65db5441 (patch)
tree38c936657bb183e162ed7b7ce02419eff3baaedb /Command/TransferInfo.hs
parent45503f3ce47c95e5c9a3f15621df02b108d1a1c9 (diff)
webapp: Progess bar fixes for many types of special remotes.
There was confusion in different parts of the progress bar code about whether an update contained the total number of bytes transferred, or the number of bytes transferred since the last update. One way this bug showed up was progress bars that seemed to stick at zero for a long time. In order to fix it comprehensively, I add a new BytesProcessed data type, that is explicitly a total quantity of bytes, not a delta. Note that this doesn't necessarily fix every problem with progress bars. Particularly, buffering can now cause progress bars to seem to run ahead of transfers, reaching 100% when data is still being uploaded.
Diffstat (limited to 'Command/TransferInfo.hs')
-rw-r--r--Command/TransferInfo.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/Command/TransferInfo.hs b/Command/TransferInfo.hs
index aacc69bb1..4bebdebcd 100644
--- a/Command/TransferInfo.hs
+++ b/Command/TransferInfo.hs
@@ -13,6 +13,7 @@ import Annex.Content
import Logs.Transfer
import Types.Key
import qualified Fields
+import Utility.Metered
def :: [Command]
def = [noCommit $ command "transferinfo" paramKey seek SectionPlumbing
@@ -50,10 +51,14 @@ start (k:[]) = do
(update, tfile, _) <- mkProgressUpdater t info
liftIO $ mapM_ void
[ tryIO $ forever $ do
- bytes <- readish <$> getLine
- maybe (error "transferinfo protocol error") update bytes
+ bytes <- readUpdate
+ maybe (error "transferinfo protocol error")
+ (update . toBytesProcessed) bytes
, tryIO $ removeFile tfile
, exitSuccess
]
stop
start _ = error "wrong number of parameters"
+
+readUpdate :: IO (Maybe Integer)
+readUpdate = readish <$> getLine