diff options
Diffstat (limited to 'Backend.hs')
-rw-r--r-- | Backend.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/Backend.hs b/Backend.hs index 38314687a..dded0d005 100644 --- a/Backend.hs +++ b/Backend.hs @@ -1,6 +1,6 @@ {- git-annex key/value backends - - - Copyright 2010,2013 Joey Hess <joey@kitenet.net> + - Copyright 2010-2014 Joey Hess <joey@kitenet.net> - - Licensed under the GNU GPL version 3 or higher. -} @@ -10,6 +10,7 @@ module Backend ( orderedList, genKey, lookupFile, + getBackend, isAnnexLink, chooseBackend, lookupBackendName, @@ -74,7 +75,7 @@ genKey' (b:bs) source = do | c == '\n' = '_' | otherwise = c -{- Looks up the key and backend corresponding to an annexed file, +{- Looks up the key corresponding to an annexed file, - by examining what the file links to. - - In direct mode, there is often no link on disk, in which case @@ -82,7 +83,7 @@ genKey' (b:bs) source = do - on disk still takes precedence over what was committed to git in direct - mode. -} -lookupFile :: FilePath -> Annex (Maybe (Key, Backend)) +lookupFile :: FilePath -> Annex (Maybe Key) lookupFile file = do mkey <- isAnnexLink file case mkey of @@ -92,14 +93,15 @@ lookupFile file = do , return Nothing ) where - makeret k = let bname = keyBackendName k in - case maybeLookupBackendName bname of - Just backend -> return $ Just (k, backend) - Nothing -> do - warning $ - "skipping " ++ file ++ - " (unknown backend " ++ bname ++ ")" - return Nothing + makeret k = return $ Just k + +getBackend :: FilePath -> Key -> Annex (Maybe Backend) +getBackend file k = let bname = keyBackendName k in + case maybeLookupBackendName bname of + Just backend -> return $ Just backend + Nothing -> do + warning $ "skipping " ++ file ++ " (unknown backend " ++ bname ++ ")" + return Nothing {- Looks up the backend that should be used for a file. - That can be configured on a per-file basis in the gitattributes file. -} |