diff options
author | Joey Hess <joey@kitenet.net> | 2013-03-28 17:03:04 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-03-28 17:04:37 -0400 |
commit | 23bfeef5d168666d17343d5484974b7b65db5441 (patch) | |
tree | 38c936657bb183e162ed7b7ce02419eff3baaedb /Logs/Transfer.hs | |
parent | 45503f3ce47c95e5c9a3f15621df02b108d1a1c9 (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 'Logs/Transfer.hs')
-rw-r--r-- | Logs/Transfer.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Logs/Transfer.hs b/Logs/Transfer.hs index e73933172..52ed03e5c 100644 --- a/Logs/Transfer.hs +++ b/Logs/Transfer.hs @@ -13,6 +13,7 @@ import Annex.Exception import qualified Git import Types.Remote import Types.Key +import Utility.Metered import Utility.Percentage import Utility.QuickCheck @@ -165,12 +166,13 @@ mkProgressUpdater t info = do mvar <- liftIO $ newMVar 0 return (liftIO . updater tfile mvar, tfile, mvar) where - updater tfile mvar bytes = modifyMVar_ mvar $ \oldbytes -> do - if (bytes - oldbytes >= mindelta) + updater tfile mvar b = modifyMVar_ mvar $ \oldbytes -> do + let newbytes = fromBytesProcessed b + if (newbytes - oldbytes >= mindelta) then do - let info' = info { bytesComplete = Just bytes } + let info' = info { bytesComplete = Just newbytes } _ <- tryIO $ writeTransferInfoFile info' tfile - return bytes + return newbytes else return oldbytes {- The minimum change in bytesComplete that is worth - updating a transfer info file for is 1% of the total |