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

View file

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

View file

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