From d3cee987caf20b309334b37bd1b89e8b9115cf0a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 5 Jun 2012 19:51:03 -0400 Subject: separate source of content from the filename associated with the key when generating a key This already made migrate's code a lot simpler. --- Backend.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'Backend.hs') diff --git a/Backend.hs b/Backend.hs index fa3266944..bde1aad78 100644 --- a/Backend.hs +++ b/Backend.hs @@ -6,6 +6,7 @@ -} module Backend ( + B.KeySource(..), list, orderedList, genKey, @@ -51,18 +52,19 @@ orderedList = do parseBackendList s = map lookupBackendName $ words s {- Generates a key for a file, trying each backend in turn until one - - accepts it. -} -genKey :: FilePath -> Maybe Backend -> Annex (Maybe (Key, Backend)) -genKey file trybackend = do + - accepts it. + -} +genKey :: B.KeySource -> Maybe Backend -> Annex (Maybe (Key, Backend)) +genKey source trybackend = do bs <- orderedList let bs' = maybe bs (: bs) trybackend - genKey' bs' file -genKey' :: [Backend] -> FilePath -> Annex (Maybe (Key, Backend)) + genKey' bs' source +genKey' :: [Backend] -> B.KeySource -> Annex (Maybe (Key, Backend)) genKey' [] _ = return Nothing -genKey' (b:bs) file = do - r <- B.getKey b file +genKey' (b:bs) source = do + r <- B.getKey b source case r of - Nothing -> genKey' bs file + Nothing -> genKey' bs source Just k -> return $ Just (makesane k, b) where -- keyNames should not contain newline characters. -- cgit v1.2.3