rsync special remote: Include annex-rsync-options when running rsync to test a key's presence.

Also, use the new withQuietOutput function to avoid running the shell to
/dev/null stderr in two other places.
This commit is contained in:
Joey Hess 2012-10-28 13:51:14 -04:00
parent 67454ab7f3
commit 9767562f65
6 changed files with 39 additions and 18 deletions

View file

@ -99,17 +99,14 @@ sshCleanup = do
stopssh socketfile = do
let (host, port) = socket2hostport socketfile
(_, params) <- sshInfo (host, port)
void $ liftIO $ do
-- "ssh -O stop" is noisy on stderr even with -q
let cmd = unwords $ toCommand $
[ Params "-O stop"
] ++ params ++ [Param host]
boolSystem "sh"
[ Param "-c"
, Param $ "ssh " ++ cmd ++ " >/dev/null 2>/dev/null"
]
-- Cannot remove the lock file; other processes may
-- be waiting on our exclusive lock to use it.
-- "ssh -O stop" is noisy on stderr even with -q
void $ liftIO $ catchMaybeIO $
withQuietOutput createProcessSuccess $
proc "ssh" $ toCommand $
[ Params "-O stop"
] ++ params ++ [Param host]
-- Cannot remove the lock file; other processes may
-- be waiting on our exclusive lock to use it.
hostport2socket :: String -> Maybe Integer -> FilePath
hostport2socket host Nothing = host

View file

@ -429,10 +429,12 @@ commitOnCleanup r a = go `after` a
| otherwise = void $ do
Just (shellcmd, shellparams) <-
git_annex_shell r "commit" [] []
-- Throw away stderr, since the remote may not
-- have a new enough git-annex shell to
-- support committing.
let cmd = shellcmd ++ " "
++ unwords (map shellEscape $ toCommand shellparams)
++ ">/dev/null 2>/dev/null"
liftIO $ boolSystem "sh" [Param "-c", Param cmd]
liftIO $ catchMaybeIO $ do
print "!!!!!!!!!!!!!"
withQuietOutput createProcessSuccess $
proc shellcmd $
toCommand shellparams

View file

@ -167,8 +167,11 @@ checkPresent r o k = do
Right <$> check
where
check = untilTrue (rsyncUrls o k) $ \u ->
liftIO $ boolSystem "sh" [Param "-c", Param (cmd u)]
cmd u = "rsync --quiet " ++ shellEscape u ++ " 2>/dev/null"
liftIO $ catchBoolIO $ do
withQuietOutput createProcessSuccess $
proc "rsync" $ toCommand $
rsyncOptions o ++ [Param u]
return True
{- Rsync params to enable resumes of sending files safely,
- ensure that files are only moved into place once complete

View file

@ -23,6 +23,7 @@ module Utility.Process (
createBackgroundProcess,
withHandle,
withBothHandles,
withQuietOutput,
createProcess,
runInteractiveProcess,
stdinHandle,
@ -185,6 +186,19 @@ withBothHandles creator p a = creator p' $ a . bothHandles
, std_err = Inherit
}
{- Forces the CreateProcessRunner to run quietly;
- both stdout and stderr are discarded. -}
withQuietOutput
:: CreateProcessRunner
-> CreateProcess
-> IO ()
withQuietOutput creator p = withFile "/dev/null" WriteMode $ \devnull -> do
let p' = p
{ std_out = UseHandle devnull
, std_err = UseHandle devnull
}
creator p' $ const $ return ()
{- Extract a desired handle from createProcess's tuple.
- These partial functions are safe as long as createProcess is run
- with appropriate parameters to set up the desired handle.

2
debian/changelog vendored
View file

@ -29,6 +29,8 @@ git-annex (3.20121018) UNRELEASED; urgency=low
which doesn't work with LDAP or NIS.
* assistant: Can use XMPP to notify other nodes that cannot be directly
pushed to about pushes.
* rsync special remote: Include annex-rsync-options when running rsync
to test a key's presence.
-- Joey Hess <joeyh@debian.org> Wed, 17 Oct 2012 14:24:10 -0400

View file

@ -30,3 +30,6 @@ OS: Ubuntu 12.04
Please provide any additional information below.
I think this fix is as easy as including the annex-rsync-options wherever rsync is called.
> I belive there was only the one place this was neglected. [[done]]
> --[[Joey]]