From 53861087d55de45ec6b24f6e452469dfa72c1644 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 13 Feb 2014 02:24:30 -0400 Subject: 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. --- Limit.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Limit.hs') 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 $ -- cgit v1.2.3