diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-02-23 14:39:56 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-02-23 14:39:56 -0400 |
commit | a5bf674bec35326cff50e17d0ed62a03bc6a28fa (patch) | |
tree | d0b6da39ca46ea0e632421ce612e5d8891eb7ab0 /Limit.hs | |
parent | 2bf90c7b56942dd80a0a44fe09eb4a35fd57da77 (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.hs | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 |