Added mimeencoding= term to annex.largefiles expressions.

* Added mimeencoding= term to annex.largefiles expressions.
  This is probably mostly useful to match non-text files with eg
  "mimeencoding=binary"
* git-annex matchexpression: Added --mimeencoding option.
This commit is contained in:
Joey Hess 2019-04-30 11:58:06 -04:00
parent 5d55f968cc
commit 9dd764e6f7
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
11 changed files with 121 additions and 41 deletions

View file

@ -135,14 +135,27 @@ preferredContentParser matchstandard matchgroupwanted getgroupmap configmap mu e
mkLargeFilesParser :: Annex (String -> [ParseResult])
mkLargeFilesParser = do
magicmime <- liftIO initMagicMimeType
let parse = parseToken $ commonTokens
magicmime <- liftIO initMagicMime
#ifdef WITH_MAGICMIME
++ [ ValueToken "mimetype" (usev $ matchMagic magicmime) ]
let mimer n f = ValueToken n (usev $ f magicmime)
#else
++ [ ValueToken "mimetype" (const $ Left "\"mimetype\" not supported; not built with MagicMime support") ]
let mimer n = ValueToken n (const $ Left "\""++n++"\" not supported; not built with MagicMime support")
#endif
let parse = parseToken $ commonTokens ++
#ifdef WITH_MAGICMIME
[ mimer "mimetype" $
matchMagic "mimetype" getMagicMimeType providedMimeType
, mimer "mimeencoding" $
matchMagic "mimeencoding" getMagicMimeEncoding providedMimeEncoding
]
#else
[ mimer "mimetype"
, mimer "mimeencoding"
,
]
#endif
return $ map parse . tokenizeMatcher
where
{- Generates a matcher for files large enough (or meeting other criteria)
- to be added to the annex, rather than directly to git. -}