From da0a1360d7b57d034620338996552752ab873045 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 17 Aug 2017 12:26:14 -0400 Subject: add annex-ignore-command and annex-sync-command configs Added remote configuration settings annex-ignore-command and annex-sync-command, which are dynamic equivilants of the annex-ignore and annex-sync configurations. For this I needed a new DynamicConfig infrastructure. Its implementation should be as fast as before when there is no dynamic config, and it caches so shell commands are only run once. Note that annex-ignore-command exits nonzero when the remote should be ignored. While that may seem backwards, it allows using the same command for it as for annex-sync-command when you want to disable both. This commit was sponsored by Trenton Cronholm on Patreon. --- RemoteDaemon/Core.hs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'RemoteDaemon') diff --git a/RemoteDaemon/Core.hs b/RemoteDaemon/Core.hs index a3e4e6400..399b1553a 100644 --- a/RemoteDaemon/Core.hs +++ b/RemoteDaemon/Core.hs @@ -10,6 +10,7 @@ module RemoteDaemon.Core (runInteractive, runNonInteractive) where import qualified Annex import Common import Types.GitConfig +import Config.DynamicConfig import RemoteDaemon.Common import RemoteDaemon.Types import RemoteDaemon.Transport @@ -139,19 +140,21 @@ genRemoteMap :: TransportHandle -> TChan Emitted -> IO RemoteMap genRemoteMap h@(TransportHandle (LocalRepo g) _) ochan = M.fromList . catMaybes <$> mapM gen (Git.remotes g) where - gen r = case Git.location r of - Git.Url u -> case M.lookup (uriScheme u) remoteTransports of - Just transport - | remoteAnnexSync gc -> do - ichan <- newTChanIO :: IO (TChan Consumed) - return $ Just - ( r - , (transport (RemoteRepo r gc) (RemoteURI u) h ichan ochan, ichan) - ) + gen r = do + gc <- atomically $ extractRemoteGitConfig g (Git.repoDescribe r) + case Git.location r of + Git.Url u -> case M.lookup (uriScheme u) remoteTransports of + Just transport -> ifM (getDynamicConfig (remoteAnnexSync gc)) + ( do + ichan <- newTChanIO :: IO (TChan Consumed) + return $ Just + ( r + , (transport (RemoteRepo r gc) (RemoteURI u) h ichan ochan, ichan) + ) + , return Nothing + ) + Nothing -> return Nothing _ -> return Nothing - _ -> return Nothing - where - gc = extractRemoteGitConfig g (Git.repoDescribe r) genTransportHandle :: IO TransportHandle genTransportHandle = do -- cgit v1.2.3