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.
This commit is contained in:
parent
66d092dc7c
commit
2ae38325d5
2 changed files with 11 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue