diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-11 17:15:45 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-11 17:32:31 -0400 |
commit | 67524c3a41a2c0b5e8c34bcbfde737ca50fc191b (patch) | |
tree | 2d6e8c0fcf36efe7274c9bc1f83c85635412be59 /Remote/Rsync.hs | |
parent | 90f10c58ba491a17d1b59e91d8c730f80cd25bce (diff) |
connect existing meters to the transfer log for downloads
Most remotes have meters in their implementations of retrieveKeyFile
already. Simply hooking these up to the transfer log makes that information
available. Easy peasy.
This is particularly valuable information for encrypted remotes, which
otherwise bypass the assistant's polling of temp files, and so don't have
good progress bars yet.
Still some work to do here (see progressbars.mdwn changes), but this
is entirely an improvement from the lack of progress bars for encrypted
downloads.
Diffstat (limited to 'Remote/Rsync.hs')
-rw-r--r-- | Remote/Rsync.hs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index a5750437d..deaf4de46 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -115,20 +115,15 @@ storeEncrypted o gpgOpts (cipher, enck) k p = withTmp enck $ \tmp -> readBytes $ L.writeFile tmp rsyncSend o p enck True tmp -retrieve :: RsyncOpts -> Key -> AssociatedFile -> FilePath -> Annex Bool -retrieve o k _ f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o Nothing - -- use inplace when retrieving to support resuming - [ Param "--inplace" - , Param u - , Param f - ] +retrieve :: RsyncOpts -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool +retrieve o k _ f p = rsyncRetrieve o k f (Just p) retrieveCheap :: RsyncOpts -> Key -> FilePath -> Annex Bool -retrieveCheap o k f = ifM (preseedTmp k f) ( retrieve o k undefined f , return False ) +retrieveCheap o k f = ifM (preseedTmp k f) ( rsyncRetrieve o k f Nothing , return False ) -retrieveEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> FilePath -> Annex Bool -retrieveEncrypted o (cipher, enck) _ f = withTmp enck $ \tmp -> - ifM (retrieve o enck undefined tmp) +retrieveEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> FilePath -> MeterUpdate -> Annex Bool +retrieveEncrypted o (cipher, enck) _ f p = withTmp enck $ \tmp -> + ifM (rsyncRetrieve o enck tmp (Just p)) ( liftIO $ catchBoolIO $ do decrypt cipher (feedFile tmp) $ readBytes $ L.writeFile f @@ -197,6 +192,15 @@ withRsyncScratchDir a = do nuke d = liftIO $ whenM (doesDirectoryExist d) $ removeDirectoryRecursive d +rsyncRetrieve :: RsyncOpts -> Key -> FilePath -> Maybe MeterUpdate -> Annex Bool +rsyncRetrieve o k dest callback = + untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o callback + -- use inplace when retrieving to support resuming + [ Param "--inplace" + , Param u + , Param dest + ] + rsyncRemote :: RsyncOpts -> (Maybe MeterUpdate) -> [CommandParam] -> Annex Bool rsyncRemote o callback params = do showOutput -- make way for progress bar |