summaryrefslogtreecommitdiff
path: root/Backend.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-10 17:37:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-10 17:37:44 -0400
commit025ded4a2dfb58a6ec0cb47b9d625d593a4e1977 (patch)
tree861010583a8d2367cb27cdf3cb0773d8af5fea74 /Backend.hs
parent10edaf6dc9c5a8f091487e8ba82ac8f54697bf0c (diff)
tweaks
Diffstat (limited to 'Backend.hs')
-rw-r--r--Backend.hs42
1 files changed, 19 insertions, 23 deletions
diff --git a/Backend.hs b/Backend.hs
index d1ff11405..a09fc0e99 100644
--- a/Backend.hs
+++ b/Backend.hs
@@ -39,23 +39,20 @@ orderedList = do
l <- Annex.getState Annex.backends -- list is cached here
if not $ null l
then return l
- else do
- s <- getstandard
- d <- Annex.getState Annex.forcebackend
- handle d s
+ else handle =<< Annex.getState Annex.forcebackend
where
- parseBackendList [] = list
- parseBackendList s = map lookupBackendName $ words s
- handle Nothing s = return s
- handle (Just "") s = return s
- handle (Just name) s = do
- let l' = lookupBackendName name : s
- Annex.changeState $ \state -> state { Annex.backends = l' }
+ handle Nothing = standard
+ handle (Just "") = standard
+ handle (Just name) = do
+ l' <- (lookupBackendName name :) <$> standard
+ Annex.changeState $ \s -> s { Annex.backends = l' }
return l'
- getstandard = do
+ standard = do
g <- gitRepo
return $ parseBackendList $
Git.configGet g "annex.backends" ""
+ parseBackendList [] = list
+ parseBackendList s = map lookupBackendName $ words s
{- Generates a key for a file, trying each backend in turn until one
- accepts it. -}
@@ -83,17 +80,15 @@ lookupFile file = do
where
getsymlink = takeFileName <$> readSymbolicLink file
makekey l = maybe (return Nothing) (makeret l) (fileKey l)
- makeret l k =
+ makeret l k = let bname = keyBackendName k in
case maybeLookupBackendName bname of
- Just backend -> return $ Just (k, backend)
- Nothing -> do
- when (isLinkToAnnex l) $
- warning skip
- return Nothing
- where
- bname = keyBackendName k
- skip = "skipping " ++ file ++
- " (unknown backend " ++ bname ++ ")"
+ Just backend -> return $ Just (k, backend)
+ Nothing -> do
+ when (isLinkToAnnex l) $ warning $
+ "skipping " ++ file ++
+ " (unknown backend " ++
+ bname ++ ")"
+ return Nothing
type BackendFile = (Maybe (Backend Annex), FilePath)
@@ -121,4 +116,5 @@ maybeLookupBackendName :: String -> Maybe (Backend Annex)
maybeLookupBackendName s
| length matches == 1 = Just $ head matches
| otherwise = Nothing
- where matches = filter (\b -> s == B.name b) list
+ where
+ matches = filter (\b -> s == B.name b) list