hide rsync progress output when metered but not in other uses of rsync

This commit is contained in:
Joey Hess 2018-03-12 18:36:07 -04:00
parent 85450f94d6
commit 1c2c8995ac
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 20 additions and 17 deletions

View file

@ -50,6 +50,7 @@ import Utility.Tmp
import Logs.Remote import Logs.Remote
import Utility.Gpg import Utility.Gpg
import Utility.SshHost import Utility.SshHost
import Messages.Progress
remote :: RemoteType remote :: RemoteType
remote = RemoteType remote = RemoteType
@ -338,9 +339,11 @@ store r rsyncopts
Remote.Directory.finalizeStoreGeneric tmpdir destdir Remote.Directory.finalizeStoreGeneric tmpdir destdir
return True return True
| Git.repoIsSsh (repo r) = if accessShell r | Git.repoIsSsh (repo r) = if accessShell r
then fileStorer $ \k f p -> Ssh.rsyncHelper (Just p) then fileStorer $ \k f p -> do
=<< Ssh.rsyncParamsRemote False r Upload k f oh <- mkOutputHandler
(AssociatedFile Nothing) Ssh.rsyncHelper oh (Just p)
=<< Ssh.rsyncParamsRemote False r Upload k f
(AssociatedFile Nothing)
else fileStorer $ Remote.Rsync.store rsyncopts else fileStorer $ Remote.Rsync.store rsyncopts
| otherwise = unsupportedUrl | otherwise = unsupportedUrl
@ -353,7 +356,8 @@ retrieve r rsyncopts
then fileRetriever $ \f k p -> do then fileRetriever $ \f k p -> do
ps <- Ssh.rsyncParamsRemote False r Download k f ps <- Ssh.rsyncParamsRemote False r Download k f
(AssociatedFile Nothing) (AssociatedFile Nothing)
unlessM (Ssh.rsyncHelper (Just p) ps) $ oh <- mkOutputHandler
unlessM (Ssh.rsyncHelper oh (Just p) ps) $
giveup "rsync failed" giveup "rsync failed"
else fileRetriever $ Remote.Rsync.retrieve rsyncopts else fileRetriever $ Remote.Rsync.retrieve rsyncopts
| otherwise = unsupportedUrl | otherwise = unsupportedUrl

View file

@ -478,7 +478,8 @@ copyFromRemote' forcersync r (State connpool _) key file dest meterupdate
where where
fallback = metered (Just meterupdate) key (return Nothing) $ \p -> fallback = metered (Just meterupdate) key (return Nothing) $ \p ->
feedprogressback $ \p' -> do feedprogressback $ \p' -> do
Ssh.rsyncHelper (Just (combineMeterUpdate p' p)) oh <- mkOutputHandlerQuiet
Ssh.rsyncHelper oh (Just (combineMeterUpdate p' p))
=<< Ssh.rsyncParamsRemote False r Download key dest file =<< Ssh.rsyncParamsRemote False r Download key dest file
{- Feed local rsync's progress info back to the remote, {- Feed local rsync's progress info back to the remote,
- by forking a feeder thread that runs - by forking a feeder thread that runs
@ -607,7 +608,8 @@ copyToRemote r (State connpool duc) key file meterupdate
-- verifies content anyway, so avoid complicating -- verifies content anyway, so avoid complicating
-- it with a local sendAnnex check and rollback. -- it with a local sendAnnex check and rollback.
unlocked <- isDirect <||> versionSupportsUnlockedPointers unlocked <- isDirect <||> versionSupportsUnlockedPointers
Ssh.rsyncHelper (Just p) oh <- mkOutputHandlerQuiet
Ssh.rsyncHelper oh (Just p)
=<< Ssh.rsyncParamsRemote unlocked r Upload key object file =<< Ssh.rsyncParamsRemote unlocked r Upload key object file
fsckOnRemote :: Git.Repo -> [CommandParam] -> Annex (IO Bool) fsckOnRemote :: Git.Repo -> [CommandParam] -> Annex (IO Bool)
@ -684,8 +686,10 @@ rsyncOrCopyFile rsyncparams src dest p =
docopy = liftIO $ watchFileSize dest p $ docopy = liftIO $ watchFileSize dest p $
copyFileExternal CopyTimeStamps src dest copyFileExternal CopyTimeStamps src dest
#endif #endif
dorsync = Ssh.rsyncHelper (Just p) $ dorsync = do
rsyncparams ++ [File src, File dest] oh <- mkOutputHandler
Ssh.rsyncHelper oh (Just p) $
rsyncparams ++ [File src, File dest]
commitOnCleanup :: Remote -> Annex a -> Annex a commitOnCleanup :: Remote -> Annex a -> Annex a
commitOnCleanup r a = go `after` a commitOnCleanup r a = go `after` a

View file

@ -16,7 +16,6 @@ import Annex.Ssh
import CmdLine.GitAnnexShell.Fields (Field, fieldName) import CmdLine.GitAnnexShell.Fields (Field, fieldName)
import qualified CmdLine.GitAnnexShell.Fields as Fields import qualified CmdLine.GitAnnexShell.Fields as Fields
import Remote.Helper.Messages import Remote.Helper.Messages
import Messages.Progress
import Utility.Metered import Utility.Metered
import Utility.Rsync import Utility.Rsync
import Utility.SshHost import Utility.SshHost
@ -111,15 +110,11 @@ dropKey r key = onRemote NoConsumeStdin r (boolSystem, return False) "dropkey"
] ]
[] []
rsyncHelper :: Maybe MeterUpdate -> [CommandParam] -> Annex Bool rsyncHelper :: OutputHandler -> Maybe MeterUpdate -> [CommandParam] -> Annex Bool
rsyncHelper m params = do rsyncHelper oh m params = do
a <- case m of a <- case m of
Nothing -> do Nothing -> return $ rsync params
showOutput -- make way for progress bar Just meter -> return $ rsyncProgress oh meter params
return $ rsync params
Just meter -> do
oh <- mkOutputHandlerQuiet
return $ rsyncProgress oh meter params
ifM (liftIO a) ifM (liftIO a)
( return True ( return True
, do , do