diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-21 16:30:16 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-21 16:30:16 -0400 |
commit | 19fde4960dc1d6c8c05efd0f5b4293c2fb52ebf9 (patch) | |
tree | 81071cf95d64b2c3f2d206d6dc30b6154a524b22 /Backend.hs | |
parent | a68e36f518589bd15fea32da273ad6fd2f288bb5 (diff) |
new fromkey subcommand, for registering urls, etc0.01
had to redo Annex monad's flag storage
Diffstat (limited to 'Backend.hs')
-rw-r--r-- | Backend.hs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Backend.hs b/Backend.hs index a427234d7..b8def21cd 100644 --- a/Backend.hs +++ b/Backend.hs @@ -14,6 +14,7 @@ - -} module Backend ( + list, storeFileKey, retrieveKeyFile, removeKey, @@ -36,24 +37,28 @@ import Types import qualified TypeInternals as Internals {- List of backends in the order to try them when storing a new key. -} -backendList :: Annex [Backend] -backendList = do - l <- Annex.backends +list :: Annex [Backend] +list = do + l <- Annex.backends -- list is cached here if (0 < length l) then return l else do all <- Annex.supportedBackends g <- Annex.gitRepo let l = parseBackendList all $ Git.configGet g "annex.backends" "" - Annex.backendsChange l - return l + backendflag <- Annex.flagGet "backend" + let l' = if (0 < length backendflag) + then (lookupBackendName all backendflag):l + else l + Annex.backendsChange $ l' + return l' where parseBackendList all s = if (length s == 0) then all else map (lookupBackendName all) $ words s -{- Looks up a backend in the list of supportedBackends -} +{- Looks up a backend in a list -} lookupBackendName :: [Backend] -> String -> Backend lookupBackendName all s = if ((length matches) /= 1) @@ -66,7 +71,7 @@ storeFileKey :: FilePath -> Annex (Maybe (Key, Backend)) storeFileKey file = do g <- Annex.gitRepo let relfile = Git.relative g file - b <- backendList + b <- list storeFileKey' b file relfile storeFileKey' [] _ _ = return Nothing storeFileKey' (b:bs) file relfile = do |