diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-09-14 15:34:15 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-09-14 15:34:15 -0400 |
commit | 9f7a68a51376e5897c63038328f3a36caaf62e4e (patch) | |
tree | c02631335f9dca388b606c4eff0f168de1e8acfe /Annex | |
parent | 96aaf2c18b8dec8fc23c42afa33722375f6e9029 (diff) |
avoid auto-enabling a remote that's already enabled
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/SpecialRemote.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Annex/SpecialRemote.hs b/Annex/SpecialRemote.hs index 4a07ebbc7..44bc666ce 100644 --- a/Annex/SpecialRemote.hs +++ b/Annex/SpecialRemote.hs @@ -8,7 +8,7 @@ module Annex.SpecialRemote where import Common.Annex -import Remote (remoteTypes) +import Remote (remoteTypes, remoteMap) import Types.Remote (RemoteConfig, RemoteConfigKey, typename, setup) import Logs.Remote import Logs.Trust @@ -70,10 +70,11 @@ autoEnableKey = "autoenable" autoEnable :: Annex () autoEnable = do - remotemap <- M.filter wanted <$> readRemoteLog - forM_ (M.toList remotemap) $ \(u, c) -> + remotemap <- M.filter configured <$> readRemoteLog + enabled <- remoteMap id + forM_ (M.toList remotemap) $ \(u, c) -> unless (u `M.member` enabled) $ do case (M.lookup nameKey c, findType c) of - (Just name, Right t) -> unlessM ((== DeadTrusted) <$> lookupTrust u) $ do + (Just name, Right t) -> whenM (canenable u) $ do showSideAction $ "Auto enabling special remote " ++ name res <- tryNonAsync $ setup t (Just u) Nothing c case res of @@ -81,5 +82,6 @@ autoEnable = do Right _ -> return () _ -> return () where - wanted rc = fromMaybe False $ + configured rc = fromMaybe False $ Git.Config.isTrue =<< M.lookup autoEnableKey rc + canenable u = (/= DeadTrusted) <$> lookupTrust u |