summaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-13 02:24:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-13 02:24:30 -0400
commit53861087d55de45ec6b24f6e452469dfa72c1644 (patch)
tree2c0274b816b8d21640d4eb4c51fabff50e1406a3 /Limit.hs
parent36f34c21f3dc8aa448f129e2a727381ca61c4c85 (diff)
limiting files based on metadata
Note that there is currently no caching, so --metadata foo=bar --metadata tag=blah will currently read the log 2x per file.
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Limit.hs b/Limit.hs
index eae608e41..bee92889d 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -23,6 +23,8 @@ import Types.Key
import Types.Group
import Types.FileMatcher
import Types.Limit
+import Types.MetaData
+import Logs.MetaData
import Logs.Group
import Logs.Unused
import Logs.Location
@@ -262,6 +264,16 @@ limitSize vs s = case readSize dataUnits s of
<$> getFileStatus (relFile fi)
return $ filesize `vs` Just sz
+addMetaData :: String -> Annex ()
+addMetaData = addLimit . limitMetaData
+
+limitMetaData :: MkLimit
+limitMetaData s = case parseMetaData s of
+ Left e -> Left e
+ Right (f, v) -> Right $ const $ checkKey (check f v)
+ where
+ check f v k = S.member v . metaDataValues f <$> getCurrentMetaData k
+
addTimeLimit :: String -> Annex ()
addTimeLimit s = do
let seconds = maybe (error "bad time-limit") durationToPOSIXTime $