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.
This commit is contained in:
parent
a18eae9a0f
commit
2075cdeb59
7 changed files with 49 additions and 11 deletions
12
Limit.hs
12
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 $
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue