diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-01-25 16:16:18 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-01-25 16:16:18 -0400 |
commit | 2d0d0b1b401cdcd9c6c1c530826a61bfc3349d12 (patch) | |
tree | 5cab04dc2cfa5d887244a4f31191158f7914a445 /Types | |
parent | 4fcd04b876f4fc4f3738d80ef66b29a76871aa2d (diff) |
matchexpression: New plumbing command to check if a preferred content expression matches some data.
Diffstat (limited to 'Types')
-rw-r--r-- | Types/FileMatcher.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Types/FileMatcher.hs b/Types/FileMatcher.hs index 377bba72a..43f05efb6 100644 --- a/Types/FileMatcher.hs +++ b/Types/FileMatcher.hs @@ -1,6 +1,6 @@ {- git-annex file matcher types - - - Copyright 2013 Joey Hess <id@joeyh.name> + - Copyright 2013-2016 Joey Hess <id@joeyh.name> - - Licensed under the GNU GPL version 3 or higher. -} @@ -10,13 +10,16 @@ module Types.FileMatcher where import Types.UUID (UUID) import Types.Key (Key) import Utility.Matcher (Matcher, Token) +import Utility.FileSize +import Control.Monad.IO.Class import qualified Data.Map as M import qualified Data.Set as S data MatchInfo = MatchingFile FileInfo | MatchingKey Key + | MatchingInfo (OptInfo FilePath) (OptInfo Key) (OptInfo FileSize) data FileInfo = FileInfo { currFile :: FilePath @@ -25,6 +28,14 @@ data FileInfo = FileInfo -- ^ filepath to match on; may be relative to top of repo or cwd } +type OptInfo a = Either (IO a) a + +-- If the OptInfo is not available, accessing it may result in eg an +-- exception being thrown. +getInfo :: MonadIO m => OptInfo a -> m a +getInfo (Right i) = pure i +getInfo (Left e) = liftIO e + type FileMatcherMap a = M.Map UUID (Utility.Matcher.Matcher (S.Set UUID -> MatchInfo -> a Bool)) type MkLimit a = String -> Either String (MatchFiles a) |