diff options
author | Joey Hess <joey@kitenet.net> | 2010-11-01 17:50:37 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-11-01 17:50:37 -0400 |
commit | 899a86f8f9601e359a894fe2839dea9cf7f47def (patch) | |
tree | 43bae4a58ce310cf790502df40f0d1f19979231f /Backend.hs | |
parent | 287e6e5c1328071ec9b934f75d5250b37a066afe (diff) |
now only need to add gitattributes lookup
Diffstat (limited to 'Backend.hs')
-rw-r--r-- | Backend.hs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Backend.hs b/Backend.hs index f1b4c2897..693e1371b 100644 --- a/Backend.hs +++ b/Backend.hs @@ -23,7 +23,8 @@ module Backend ( retrieveKeyFile, removeKey, hasKey, - lookupFile + lookupFile, + chooseBackends ) where import Control.Monad.State @@ -74,12 +75,15 @@ maybeLookupBackendName bs s = where matches = filter (\b -> s == Internals.name b) bs {- Attempts to store a file in one of the backends. -} -storeFileKey :: FilePath -> Annex (Maybe (Key, Backend)) -storeFileKey file = do +storeFileKey :: FilePath -> Maybe Backend -> Annex (Maybe (Key, Backend)) +storeFileKey file trybackend = do g <- Annex.gitRepo let relfile = Git.relative g file - b <- list - storeFileKey' b file relfile + bs <- list + let bs' = case trybackend of + Nothing -> bs + Just backend -> backend:bs + storeFileKey' bs' file relfile storeFileKey' :: [Backend] -> FilePath -> FilePath -> Annex (Maybe (Key, Backend)) storeFileKey' [] _ _ = return Nothing storeFileKey' (b:bs) file relfile = do @@ -136,3 +140,11 @@ lookupFile file = do kname = keyName k skip = "skipping " ++ file ++ " (unknown backend " ++ bname ++ ")" + +{- Looks up the backends that should be used for each file in a list. + - That can be configured on a per-file basis in the gitattributes file. + -} +chooseBackends :: [FilePath] -> Annex [(FilePath, Maybe Backend)] +chooseBackends fs = do + -- TODO + return $ map (\f -> (f, Nothing)) fs |