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

@ -1,6 +1,6 @@
{- git-annex file matcher types
-
- Copyright 2013-2016 Joey Hess <id@joeyh.name>
- Copyright 2013-2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -9,6 +9,7 @@ module Types.FileMatcher where
import Types.UUID (UUID)
import Types.Key (Key, AssociatedFile)
import Types.Mime
import Utility.Matcher (Matcher, Token)
import Utility.FileSize
@ -16,12 +17,11 @@ import Control.Monad.IO.Class
import qualified Data.Map as M
import qualified Data.Set as S
-- Information about a file or a key that can be matched on.
data MatchInfo
= MatchingFile FileInfo
| MatchingKey Key AssociatedFile
| MatchingInfo (OptInfo FilePath) (OptInfo Key) (OptInfo FileSize) (OptInfo MimeType)
type MimeType = String
| MatchingInfo ProvidedInfo
data FileInfo = FileInfo
{ currFile :: FilePath
@ -30,6 +30,16 @@ data FileInfo = FileInfo
-- ^ filepath to match on; may be relative to top of repo or cwd
}
-- This is used when testing a matcher, with values to match against
-- provided by the user, rather than queried from files.
data ProvidedInfo = ProvidedInfo
{ providedFilePath :: OptInfo FilePath
, providedKey :: OptInfo Key
, providedFileSize :: OptInfo FileSize
, providedMimeType :: OptInfo MimeType
, providedMimeEncoding :: OptInfo MimeEncoding
}
type OptInfo a = Either (IO a) a
-- If the OptInfo is not available, accessing it may result in eg an

12
Types/Mime.hs Normal file
View file

@ -0,0 +1,12 @@
{- git-annex mime types
-
- Copyright 2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Types.Mime where
type MimeType = String
type MimeEncoding = String