summaryrefslogtreecommitdiff
path: root/Backend.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-17 18:03:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-17 18:03:39 -0400
commite9b6c350b15a93d82affadfabca18b3e95840cb1 (patch)
tree48230725260d92997b1fe58a698f57568f398475 /Backend.hs
parentc7c12e735b806eecd62048b822af2d8802671d3f (diff)
replace (Key, Backend) with Key
Only fsck and reinject and the test suite used the Backend, and they can look it up as needed from the Key. This simplifies the code and also speeds it up. There is a small behavior change here. Before, all commands would warn when acting on an annexed file with an unknown backend. Now, only fsck and reinject show that warning.
Diffstat (limited to 'Backend.hs')
-rw-r--r--Backend.hs24
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. -}