diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-10 21:33:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-10 21:33:22 -0400 |
commit | d103ab9e49de11f69f0b804157e597a3e9a12566 (patch) | |
tree | a995f3adbabcaba0f8fa64d412402d4fae7ec72d /Remote | |
parent | 9eb48667f0fa8188cf197634acd7b954179d88e8 (diff) |
Add progress display for transfers to/from external special remotes.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/External.hs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/Remote/External.hs b/Remote/External.hs index 26f511551..96d665c26 100644 --- a/Remote/External.hs +++ b/Remote/External.hs @@ -92,16 +92,18 @@ externalSetup mu c = do store :: External -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool store external k _f p = sendAnnex k rollback $ \f -> - storeHelper external k f p + metered (Just p) k $ + storeHelper external k f where rollback = void $ remove external k storeEncrypted :: External -> [CommandParam] -> (Cipher, Key) -> Key -> MeterUpdate -> Annex Bool storeEncrypted external gpgOpts (cipher, enck) k p = withTmp enck $ \tmp -> sendAnnex k rollback $ \src -> do - liftIO $ encrypt gpgOpts cipher (feedFile src) $ - readBytes $ L.writeFile tmp - storeHelper external enck tmp p + metered (Just p) k $ \meterupdate -> do + liftIO $ encrypt gpgOpts cipher (feedFile src) $ + readBytes $ L.writeFile tmp + storeHelper external enck tmp meterupdate where rollback = void $ remove external enck @@ -118,17 +120,19 @@ storeHelper external k f p = safely $ _ -> Nothing retrieve :: External -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool -retrieve external k _f d p = retrieveHelper external k d p +retrieve external k _f d p = metered (Just p) k $ + retrieveHelper external k d retrieveEncrypted :: External -> (Cipher, Key) -> Key -> FilePath -> MeterUpdate -> Annex Bool -retrieveEncrypted external (cipher, enck) _ f p = withTmp enck $ \tmp -> - ifM (retrieveHelper external enck tmp p) - ( liftIO $ catchBoolIO $ do - decrypt cipher (feedFile tmp) $ - readBytes $ L.writeFile f - return True - , return False - ) +retrieveEncrypted external (cipher, enck) k f p = withTmp enck $ \tmp -> + metered (Just p) k $ \meterupdate -> + ifM (retrieveHelper external enck tmp meterupdate) + ( liftIO $ catchBoolIO $ do + decrypt cipher (feedFile tmp) $ + readBytes $ L.writeFile f + return True + , return False + ) retrieveHelper :: External -> Key -> FilePath -> MeterUpdate -> Annex Bool retrieveHelper external k d p = safely $ |