summaryrefslogtreecommitdiff
path: root/Types/FileMatcher.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-01-25 16:16:18 -0400
committerJoey Hess <joeyh@joeyh.name>2016-01-25 16:16:18 -0400
commitd3ba9fe5c85d79f98949392aa34d4436dd746b3b (patch)
tree44f884cd3ac9366961006a0b3aec2eab85eb5c3f /Types/FileMatcher.hs
parent4b569c9e7f1091785f7a7a3925881c2a17f87352 (diff)
matchexpression: New plumbing command to check if a preferred content expression matches some data.
Diffstat (limited to 'Types/FileMatcher.hs')
-rw-r--r--Types/FileMatcher.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/Types/FileMatcher.hs b/Types/FileMatcher.hs
index 377bba72a8..43f05efb6a 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)