summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-20 17:13:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-20 17:15:46 -0400
commit6ef82665de86195a7da6cffcba40874eba06424f (patch)
treea9fb4874525b49d0693c2f7a5dac27afe3471cc1
parent47250a153a6c5a2864fec15fb136290683aeb1c6 (diff)
add annex.sshcaching config setting
-rw-r--r--Annex/Ssh.hs29
-rw-r--r--doc/git-annex.mdwn4
2 files changed, 23 insertions, 10 deletions
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index cd832a373..7f5ba48d8 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -15,28 +15,37 @@ import System.IO.Error (try)
import Common.Annex
import Annex.LockPool
+import qualified Git
+import qualified Git.Config
{- Generates parameters to ssh to a given host (or user@host) on a given
- port, with connection caching. -}
sshParams :: (String, Maybe Integer) -> Annex [CommandParam]
-sshParams (host, port) = do
- cleanstale
- (socketfile, params) <- sshInfo (host, port)
- liftIO $ createDirectoryIfMissing True $ parentDir socketfile
- lockFile $ socket2lock socketfile
- return params
+sshParams (host, port) = go =<< sshInfo (host, port)
where
+ go (Nothing, params) = return params
+ go (Just socketfile, params) = do
+ cleanstale
+ liftIO $ createDirectoryIfMissing True $ parentDir socketfile
+ lockFile $ socket2lock socketfile
+ return params
-- If the lock pool is empty, this is the first ssh of this
-- run. There could be stale ssh connections hanging around
-- from a previous git-annex run that was interrupted.
cleanstale = whenM (null . filter isLock . M.keys <$> getPool) $
sshCleanup
-sshInfo :: (String, Maybe Integer) -> Annex (FilePath, [CommandParam])
+sshInfo :: (String, Maybe Integer) -> Annex (Maybe FilePath, [CommandParam])
sshInfo (host, port) = do
- dir <- fromRepo $ gitAnnexSshDir
- let socketfile = dir </> hostport2socket host port
- return $ (socketfile, cacheParams socketfile ++ portParams port ++ [Param host])
+ caching <- Git.configTrue <$> fromRepo (Git.Config.get "annex.sshcaching" "true")
+ if caching
+ then do
+ dir <- fromRepo $ gitAnnexSshDir
+ let socketfile = dir </> hostport2socket host port
+ return $ (Just socketfile, cacheParams socketfile ++ params)
+ else return (Nothing, params)
+ where
+ params = portParams port ++ [Param host]
cacheParams :: FilePath -> [CommandParam]
cacheParams socketfile =
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index a377665c6..148b6336d 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -575,6 +575,10 @@ Here are all the supported configuration settings.
Automatically maintained, and used to automate upgrades between versions.
+* `annex.sshcaching`
+
+ By default, git-annex caches ssh connections. To disable this, set to `false`.
+
* `remote.<name>.annex-cost`
When determining which repository to