summaryrefslogtreecommitdiff
path: root/Backend.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-02-13 23:42:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-02-13 23:52:21 -0400
commitcbaebf538a8659193fb3dbb4f32e0f918a385af3 (patch)
tree63a86b6f3ffe8e08f8610a267c2c19bb2389bfc8 /Backend.hs
parentd35a8d85b5ee9ce3d6057300e21729183cce802b (diff)
rework git check-attr interface
Now gitattributes are looked up, efficiently, in only the places that really need them, using the same approach used for cat-file. The old CheckAttr code seemed very fragile, in the way it streamed files through git check-attr. I actually found that cad8824852aa0623dc41eac02a9e2bae47d88ec4 was still deadlocking with ghc 7.4, at the end of adding a lot of files. This should fix that problem, and avoid future ones. The best part is that this removes withAttrFilesInGit and withNumCopies, which were complicated Seek methods, as well as simplfying the types for several other Seek methods that had a Backend tupled in.
Diffstat (limited to 'Backend.hs')
-rw-r--r--Backend.hs21
1 files changed, 8 insertions, 13 deletions
diff --git a/Backend.hs b/Backend.hs
index e351bb3b2..50c89ecc5 100644
--- a/Backend.hs
+++ b/Backend.hs
@@ -6,12 +6,11 @@
-}
module Backend (
- BackendFile,
list,
orderedList,
genKey,
lookupFile,
- chooseBackends,
+ chooseBackend,
lookupBackendName,
maybeLookupBackendName
) where
@@ -22,6 +21,7 @@ import Common.Annex
import qualified Git.Config
import qualified Git.CheckAttr
import qualified Annex
+import Annex.CheckAttr
import Types.Key
import qualified Types.Backend as B
@@ -93,20 +93,15 @@ lookupFile file = do
bname ++ ")"
return Nothing
-type BackendFile = (Maybe Backend, FilePath)
-
-{- Looks up the backends that should be used for each file in a list.
+{- Looks up the backend that should be used for a file.
- That can be configured on a per-file basis in the gitattributes file.
-}
-chooseBackends :: [FilePath] -> Annex [BackendFile]
-chooseBackends fs = Annex.getState Annex.forcebackend >>= go
+chooseBackend :: FilePath -> Annex (Maybe Backend)
+chooseBackend f = Annex.getState Annex.forcebackend >>= go
where
- go Nothing = do
- pairs <- inRepo $ Git.CheckAttr.lookup "annex.backend" fs
- return $ map (\(f,b) -> (maybeLookupBackendName b, f)) pairs
- go (Just _) = do
- l <- orderedList
- return $ map (\f -> (Just $ Prelude.head l, f)) fs
+ go Nothing = maybeLookupBackendName <$>
+ checkAttr "annex.backend" f
+ go (Just _) = Just . Prelude.head <$> orderedList
{- Looks up a backend by name. May fail if unknown. -}
lookupBackendName :: String -> Backend