Avoid crashing when built with MagicMime support, but when the magic database cannot be loaded.
This commit is contained in:
parent
2bf90c7b56
commit
a5bf674bec
3 changed files with 9 additions and 4 deletions
|
@ -129,8 +129,10 @@ preferredContentParser matchstandard matchgroupwanted getgroupmap configmap mu e
|
||||||
mkLargeFilesParser :: Annex (String -> [ParseResult])
|
mkLargeFilesParser :: Annex (String -> [ParseResult])
|
||||||
mkLargeFilesParser = do
|
mkLargeFilesParser = do
|
||||||
#ifdef WITH_MAGICMIME
|
#ifdef WITH_MAGICMIME
|
||||||
magicmime <- liftIO $ magicOpen [MagicMimeType]
|
magicmime <- liftIO $ catchMaybeIO $ do
|
||||||
liftIO $ magicLoadDefault magicmime
|
m <- magicOpen [MagicMimeType]
|
||||||
|
liftIO $ magicLoadDefault m
|
||||||
|
return m
|
||||||
#endif
|
#endif
|
||||||
let parse = parseToken $ commonTokens
|
let parse = parseToken $ commonTokens
|
||||||
#ifdef WITH_MAGICMIME
|
#ifdef WITH_MAGICMIME
|
||||||
|
|
5
Limit.hs
5
Limit.hs
|
@ -97,14 +97,15 @@ matchGlobFile glob = go
|
||||||
go (MatchingInfo af _ _ _) = matchGlob cglob <$> getInfo af
|
go (MatchingInfo af _ _ _) = matchGlob cglob <$> getInfo af
|
||||||
|
|
||||||
#ifdef WITH_MAGICMIME
|
#ifdef WITH_MAGICMIME
|
||||||
matchMagic :: Magic -> MkLimit Annex
|
matchMagic :: Maybe Magic -> MkLimit Annex
|
||||||
matchMagic magic glob = Right $ const go
|
matchMagic (Just magic) glob = Right $ const go
|
||||||
where
|
where
|
||||||
cglob = compileGlob glob CaseSensative -- memoized
|
cglob = compileGlob glob CaseSensative -- memoized
|
||||||
go (MatchingKey _) = pure False
|
go (MatchingKey _) = pure False
|
||||||
go (MatchingFile fi) = liftIO $ catchBoolIO $
|
go (MatchingFile fi) = liftIO $ catchBoolIO $
|
||||||
matchGlob cglob <$> magicFile magic (matchFile fi)
|
matchGlob cglob <$> magicFile magic (matchFile fi)
|
||||||
go (MatchingInfo _ _ _ mimeval) = matchGlob cglob <$> getInfo mimeval
|
go (MatchingInfo _ _ _ mimeval) = matchGlob cglob <$> getInfo mimeval
|
||||||
|
matchMagic Nothing _ = Left "unable to load magic database; \"mimetype\" cannot be used"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{- Adds a limit to skip files not believed to be present
|
{- Adds a limit to skip files not believed to be present
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -9,6 +9,8 @@ git-annex (6.20160218) UNRELEASED; urgency=medium
|
||||||
* info: Mention when run in a dead repository.
|
* info: Mention when run in a dead repository.
|
||||||
* Linux and OSX standalone builds put the bundled gpg last in PATH,
|
* Linux and OSX standalone builds put the bundled gpg last in PATH,
|
||||||
so any system gpg will be preferred over it.
|
so any system gpg will be preferred over it.
|
||||||
|
* Avoid crashing when built with MagicMime support, but when the magic
|
||||||
|
database cannot be loaded.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Thu, 18 Feb 2016 13:09:21 -0400
|
-- Joey Hess <id@joeyh.name> Thu, 18 Feb 2016 13:09:21 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue