diff options
author | Joey Hess <joey@kitenet.net> | 2011-03-27 21:43:25 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-03-27 21:43:25 -0400 |
commit | 6b5918c295715d0599005c9367f5dab5468169c5 (patch) | |
tree | bf54f1fc8b75084d3f1ddd74c260c8521e1eb51c /Remote.hs | |
parent | 28bf28a73c503c7c2d9add38e964149355bb9e50 (diff) |
some reorg and further remote generalization
Diffstat (limited to 'Remote.hs')
-rw-r--r-- | Remote.hs | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -25,20 +25,35 @@ module Remote ( import Control.Monad.State (liftIO) import Control.Monad (when, liftM) import Data.List +import Data.String.Utils import RemoteClass import qualified Remote.Git -import qualified Remote.S3 +--import qualified Remote.S3 import Types import UUID import qualified Annex import Trust import LocationLog +import Messages -{- add generators for new Remotes here -} -generators :: [Annex [Remote Annex]] +{- Add generators for new Remotes here. -} +generators :: [Annex (RemoteGenerator Annex)] generators = [Remote.Git.generate] +{- Runs a list of generators. -} +runGenerators :: [Annex (RemoteGenerator Annex)] -> Annex [Remote Annex] +runGenerators gs = do + (actions, expensive) <- collect ([], []) gs + when (not $ null expensive) $ + showNote $ "getting UUID for " ++ join ", " expensive + sequence actions + where + collect v [] = return v + collect (actions, expensive) (x:xs) = do + (a, e) <- x + collect (a++actions, e++expensive) xs + {- Builds a list of all available Remotes. - Since doing so can be expensive, the list is cached in the Annex. -} genList :: Annex [Remote Annex] @@ -46,8 +61,7 @@ genList = do rs <- Annex.getState Annex.remotes if null rs then do - lists <- sequence generators - let rs' = concat lists + rs' <- runGenerators generators Annex.changeState $ \s -> s { Annex.remotes = rs' } return rs' else return rs |