diff options
author | 2012-01-10 13:11:16 -0400 | |
---|---|---|
committer | 2012-01-10 13:32:38 -0400 | |
commit | 07cacbeee95b377e1bf4111e4d4b30190956c585 (patch) | |
tree | 17249f177a6ffde3d2f524ee66a9a6b2530bd92e /Remote | |
parent | 0d5c4022105a393a4eac76b09940f8b22fa0a56c (diff) |
break module dependancy loop
A PITA but worth it to clean up the trust configuration code.
Diffstat (limited to 'Remote')
-rw-r--r-- | Remote/List.hs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Remote/List.hs b/Remote/List.hs new file mode 100644 index 000000000..e589b4401 --- /dev/null +++ b/Remote/List.hs @@ -0,0 +1,58 @@ +{- git-annex remote list + - + - Copyright 2011 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Remote.List where + +import qualified Data.Map as M + +import Common.Annex +import qualified Annex +import Logs.Remote +import Types.Remote +import Annex.UUID +import Config + +import qualified Remote.Git +import qualified Remote.S3 +import qualified Remote.Bup +import qualified Remote.Directory +import qualified Remote.Rsync +import qualified Remote.Web +import qualified Remote.Hook + +remoteTypes :: [RemoteType] +remoteTypes = + [ Remote.Git.remote + , Remote.S3.remote + , Remote.Bup.remote + , Remote.Directory.remote + , Remote.Rsync.remote + , Remote.Web.remote + , Remote.Hook.remote + ] + +{- Builds a list of all available Remotes. + - Since doing so can be expensive, the list is cached. -} +remoteList :: Annex [Remote] +remoteList = do + rs <- Annex.getState Annex.remotes + if null rs + then do + m <- readRemoteLog + rs' <- concat <$> mapM (process m) remoteTypes + Annex.changeState $ \s -> s { Annex.remotes = rs' } + return rs' + else return rs + where + process m t = enumerate t >>= mapM (gen m t) + gen m t r = do + u <- getRepoUUID r + generate t r u (M.lookup u m) + +{- All remotes that are not ignored. -} +enabledRemoteList :: Annex [Remote] +enabledRemoteList = filterM (repoNotIgnored . repo) =<< remoteList |