From 2d0d0b1b401cdcd9c6c1c530826a61bfc3349d12 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 25 Jan 2016 16:16:18 -0400 Subject: matchexpression: New plumbing command to check if a preferred content expression matches some data. --- Types/FileMatcher.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Types') 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 + - Copyright 2013-2016 Joey Hess - - 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) -- cgit v1.2.3