From a5bf674bec35326cff50e17d0ed62a03bc6a28fa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 23 Feb 2016 14:39:56 -0400 Subject: Avoid crashing when built with MagicMime support, but when the magic database cannot be loaded. --- Limit.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Limit.hs') diff --git a/Limit.hs b/Limit.hs index 9bf5e22d95..174d4582d3 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 -- cgit v1.2.3