diff options
author | 2012-09-20 13:50:21 -0400 | |
---|---|---|
committer | 2012-09-20 13:51:51 -0400 | |
commit | 2ae38325d5ba1fde3de0c53197658a3febc227f4 (patch) | |
tree | ef7641384d3bbe38788153a463e2d88245858389 | |
parent | 66d092dc7c5731b75bd69887ae5b6a0e37625b90 (diff) |
hook rsync special remote up to the progress reporting
Easy!
Note that with an encrypted remote, rsync will be sending a little more
data than the key size, so displayed progress may get to 100% slightly
quicker than it should. I doubt this is a big enough effect to worry about.
-rw-r--r-- | Remote/Rsync.hs | 19 | ||||
-rw-r--r-- | doc/design/assistant/progressbars.mdwn | 2 |
2 files changed, 11 insertions, 10 deletions
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index aba427d4b..5384920fb 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -105,16 +105,16 @@ rsyncUrls o k = map use annexHashes f = keyFile k store :: RsyncOpts -> Key -> AssociatedFile -> ProgressCallback -> Annex Bool -store o k _f p = rsyncSend o k <=< inRepo $ gitAnnexLocation k +store o k _f p = rsyncSend o p k <=< inRepo $ gitAnnexLocation k storeEncrypted :: RsyncOpts -> (Cipher, Key) -> Key -> ProgressCallback -> Annex Bool storeEncrypted o (cipher, enck) k p = withTmp enck $ \tmp -> do src <- inRepo $ gitAnnexLocation k liftIO $ withEncryptedContent cipher (L.readFile src) $ L.writeFile tmp - rsyncSend o enck tmp + rsyncSend o p enck tmp retrieve :: RsyncOpts -> Key -> AssociatedFile -> FilePath -> Annex Bool -retrieve o k _ f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o +retrieve o k _ f = untilTrue (rsyncUrls o k) $ \u -> rsyncRemote o Nothing -- use inplace when retrieving to support resuming [ Param "--inplace" , Param u @@ -191,10 +191,10 @@ withRsyncScratchDir a = do nuke d = liftIO $ whenM (doesDirectoryExist d) $ removeDirectoryRecursive d -rsyncRemote :: RsyncOpts -> [CommandParam] -> Annex Bool -rsyncRemote o params = do +rsyncRemote :: RsyncOpts -> (Maybe ProgressCallback) -> [CommandParam] -> Annex Bool +rsyncRemote o callback params = do showOutput -- make way for progress bar - ifM (liftIO $ rsync $ rsyncOptions o ++ defaultParams ++ params) + ifM (liftIO $ (maybe rsync rsyncProgress callback) ps) ( return True , do showLongNote "rsync failed -- run git annex again to resume file transfer" @@ -202,16 +202,17 @@ rsyncRemote o params = do ) where defaultParams = [Params "--progress"] + ps = rsyncOptions o ++ defaultParams ++ params {- To send a single key is slightly tricky; need to build up a temporary directory structure to pass to rsync so it can create the hash directories. -} -rsyncSend :: RsyncOpts -> Key -> FilePath -> Annex Bool -rsyncSend o k src = withRsyncScratchDir $ \tmp -> do +rsyncSend :: RsyncOpts -> ProgressCallback -> Key -> FilePath -> Annex Bool +rsyncSend o callback k src = withRsyncScratchDir $ \tmp -> do let dest = tmp </> Prelude.head (keyPaths k) liftIO $ createDirectoryIfMissing True $ parentDir dest liftIO $ createLink src dest - rsyncRemote o + rsyncRemote o (Just callback) [ Param "--recursive" , partialParams -- tmp/ to send contents of tmp dir diff --git a/doc/design/assistant/progressbars.mdwn b/doc/design/assistant/progressbars.mdwn index 7a7cf31ad..6b1521af6 100644 --- a/doc/design/assistant/progressbars.mdwn +++ b/doc/design/assistant/progressbars.mdwn @@ -23,7 +23,7 @@ the ProgressCallback as the upload progresses. --server --sender` and in that mode it does not report progress info. So downloads initiated by other repos do not show progress in the repo doing the uploading. -* rsync +* rsync: **done** * directory * web: Not applicable; does not upload * S3 |