summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Limit.hs b/Limit.hs
index 9bf5e22d9..dc38b172d 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -23,6 +23,7 @@ import Types.TrustLevel
import Types.Group
import Types.FileMatcher
import Types.MetaData
+import Annex.MetaData
import Logs.MetaData
import Logs.Group
import Logs.Unused
@@ -97,14 +98,15 @@ matchGlobFile glob = go
go (MatchingInfo af _ _ _) = matchGlob cglob <$> getInfo af
#ifdef WITH_MAGICMIME
-matchMagic :: Magic -> MkLimit Annex
-matchMagic magic glob = Right $ const go
+matchMagic :: Maybe Magic -> MkLimit Annex
+matchMagic (Just magic) glob = Right $ const go
where
cglob = compileGlob glob CaseSensative -- memoized
go (MatchingKey _) = pure False
go (MatchingFile fi) = liftIO $ catchBoolIO $
matchGlob cglob <$> magicFile magic (matchFile fi)
go (MatchingInfo _ _ _ mimeval) = matchGlob cglob <$> getInfo mimeval
+matchMagic Nothing _ = Left "unable to load magic database; \"mimetype\" cannot be used"
#endif
{- Adds a limit to skip files not believed to be present
@@ -277,14 +279,12 @@ addMetaData :: String -> Annex ()
addMetaData = addLimit . limitMetaData
limitMetaData :: MkLimit Annex
-limitMetaData s = case parseMetaData s of
+limitMetaData s = case parseMetaDataMatcher s of
Left e -> Left e
- Right (f, v) ->
- let cglob = compileGlob (fromMetaValue v) CaseInsensative
- in Right $ const $ checkKey (check f cglob)
+ Right (f, matching) -> Right $ const $ checkKey (check f matching)
where
- check f cglob k = not . S.null
- . S.filter (matchGlob cglob . fromMetaValue)
+ check f matching k = not . S.null
+ . S.filter matching
. metaDataValues f <$> getCurrentMetaData k
addTimeLimit :: String -> Annex ()