diff options
author | Joey Hess <joey@kitenet.net> | 2012-09-19 16:08:37 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-19 16:08:37 -0400 |
commit | aff09a1f33be7b3df182a7c85b30a2d3e04833c7 (patch) | |
tree | 6d7cb4ed4e9483c14bdd832c9af848dc1b866789 /Command | |
parent | 3c81d70c1beccb50571281ef35c9123bac006b7c (diff) |
add a progress callback to storeKey, and threaded it all the way through
Transfer info files are updated when the callback is called, updating
the number of bytes transferred.
Left unused p variables at every place the callback should be used.
Which is rather a lot..
Diffstat (limited to 'Command')
-rw-r--r-- | Command/RecvKey.hs | 2 | ||||
-rw-r--r-- | Command/SendKey.hs | 8 | ||||
-rw-r--r-- | Command/TransferKey.hs | 4 |
3 files changed, 8 insertions, 6 deletions
diff --git a/Command/RecvKey.hs b/Command/RecvKey.hs index 49f0d9e98..07e0eab80 100644 --- a/Command/RecvKey.hs +++ b/Command/RecvKey.hs @@ -25,7 +25,7 @@ seek = [withKeys start] start :: Key -> CommandStart start key = ifM (inAnnex key) ( error "key is already present in annex" - , fieldTransfer Download key $ do + , fieldTransfer Download key $ \p -> do ifM (getViaTmp key $ liftIO . rsyncServerReceive) ( do -- forcibly quit after receiving one key, diff --git a/Command/SendKey.hs b/Command/SendKey.hs index 6fcbf7075..79cc61876 100644 --- a/Command/SendKey.hs +++ b/Command/SendKey.hs @@ -12,6 +12,7 @@ import Command import Annex.Content import Utility.Rsync import Logs.Transfer +import Types.Remote import qualified Fields def :: [Command] @@ -23,7 +24,7 @@ seek = [withKeys start] start :: Key -> CommandStart start key = ifM (inAnnex key) - ( fieldTransfer Upload key $ do + ( fieldTransfer Upload key $ \p -> do file <- inRepo $ gitAnnexLocation key liftIO $ rsyncServerSend file , do @@ -31,10 +32,11 @@ start key = ifM (inAnnex key) liftIO exitFailure ) -fieldTransfer :: Direction -> Key -> Annex Bool -> CommandStart +fieldTransfer :: Direction -> Key -> (ProgressCallback -> Annex Bool) -> CommandStart fieldTransfer direction key a = do afile <- Fields.getField Fields.associatedFile - ok <- maybe a (\u -> runTransfer (Transfer direction (toUUID u) key) afile a) + ok <- maybe (a $ const noop) + (\u -> runTransfer (Transfer direction (toUUID u) key) afile a) =<< Fields.getField Fields.remoteUUID if ok then liftIO exitSuccess diff --git a/Command/TransferKey.hs b/Command/TransferKey.hs index ed6fbb68c..793dbeb56 100644 --- a/Command/TransferKey.hs +++ b/Command/TransferKey.hs @@ -43,8 +43,8 @@ start to from file key = toPerform :: Remote -> Key -> AssociatedFile -> CommandPerform toPerform remote key file = next $ - upload (uuid remote) key file $ do - ok <- Remote.storeKey remote key file + upload (uuid remote) key file $ \p -> do + ok <- Remote.storeKey remote key file p when ok $ Remote.logStatus remote key InfoPresent return ok |