diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-13 02:24:30 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-13 02:24:30 -0400 |
commit | 2075cdeb5937c13880dcbf4c734e990e95f25ba7 (patch) | |
tree | 96d421f72fa7361d49e5646b0b1137d1168aad89 /Limit.hs | |
parent | a18eae9a0f9cbc598b2e44937029943cd43eba7f (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.hs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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 $ |