summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-23 14:39:56 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-23 14:39:56 -0400
commit462217110db8f07463b28bb77dcbdb7c773eff49 (patch)
treef2c3f31f2cae2f9ee66d63c5e5b6140c2b6f5f55 /Limit.hs
parent23ed99f1874978fa415a55110b3291ff1381ae66 (diff)
Avoid crashing when built with MagicMime support, but when the magic database cannot be loaded.
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/Limit.hs b/Limit.hs
index 9bf5e22d9..174d4582d 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -97,14 +97,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