diff options
-rw-r--r-- | Annex/FileMatcher.hs | 28 | ||||
-rw-r--r-- | Limit.hs | 11 | ||||
-rw-r--r-- | Logs/PreferredContent.hs | 2 |
3 files changed, 19 insertions, 22 deletions
diff --git a/Annex/FileMatcher.hs b/Annex/FileMatcher.hs index 641fe49c9..e3482ec8b 100644 --- a/Annex/FileMatcher.hs +++ b/Annex/FileMatcher.hs @@ -71,33 +71,33 @@ exprParser matchstandard matchgroupwanted getgroupmap configmap mu expr = preferreddir = fromMaybe "public" $ M.lookup "preferreddir" =<< (`M.lookup` configmap) =<< mu -parseToken :: FileMatcher Annex -> FileMatcher Annex -> MkLimit Annex -> MkLimit Annex -> Annex GroupMap -> String -> Either String (Token (MatchFiles Annex)) +parseToken :: FileMatcher Annex -> FileMatcher Annex -> MatchFiles Annex -> MatchFiles Annex -> Annex GroupMap -> String -> Either String (Token (MatchFiles Annex)) parseToken matchstandard matchgroupwanted checkpresent checkpreferreddir getgroupmap t | t `elem` tokens = Right $ token t | otherwise = case t of "standard" -> call matchstandard "groupwanted" -> call matchgroupwanted - "present" -> use checkpresent - "inpreferreddir" -> use checkpreferreddir + "present" -> simply checkpresent + "inpreferreddir" -> simply checkpreferreddir "unused" -> simply limitUnused "anything" -> simply limitAnything "nothing" -> simply limitNothing _ -> case k of - "include" -> use limitInclude - "exclude" -> use limitExclude - "copies" -> use limitCopies - "lackingcopies" -> use $ limitLackingCopies False - "approxlackingcopies" -> use $ limitLackingCopies True - "inbackend" -> use limitInBackend - "largerthan" -> use $ limitSize (>) - "smallerthan" -> use $ limitSize (<) - "metadata" -> use limitMetaData - "inallgroup" -> use $ limitInAllGroup getgroupmap + "include" -> usev limitInclude + "exclude" -> usev limitExclude + "copies" -> usev limitCopies + "lackingcopies" -> usev $ limitLackingCopies False + "approxlackingcopies" -> usev $ limitLackingCopies True + "inbackend" -> usev limitInBackend + "largerthan" -> usev $ limitSize (>) + "smallerthan" -> usev $ limitSize (<) + "metadata" -> usev limitMetaData + "inallgroup" -> usev $ limitInAllGroup getgroupmap _ -> Left $ "near " ++ show t where (k, v) = separate (== '=') t simply = Right . Operation - use a = Operation <$> a v + usev a = Operation <$> a v call sub = Right $ Operation $ \notpresent mi -> matchMrun sub $ \a -> a notpresent mi @@ -118,11 +118,8 @@ addIn s = addLimit =<< mk else inAnnex key {- Limit to content that is currently present on a uuid. -} -limitPresent :: Maybe UUID -> MkLimit Annex -limitPresent u _ = Right $ matchPresent u - -matchPresent :: Maybe UUID -> MatchFiles Annex -matchPresent u _ = checkKey $ \key -> do +limitPresent :: Maybe UUID -> MatchFiles Annex +limitPresent u _ = checkKey $ \key -> do hereu <- getUUID if u == Just hereu || isNothing u then inAnnex key @@ -131,8 +128,8 @@ matchPresent u _ = checkKey $ \key -> do return $ maybe False (`elem` us) u {- Limit to content that is in a directory, anywhere in the repository tree -} -limitInDir :: FilePath -> MkLimit Annex -limitInDir dir = const $ Right $ const go +limitInDir :: FilePath -> MatchFiles Annex +limitInDir dir = const go where go (MatchingFile fi) = checkf $ matchFile fi go (MatchingKey _) = return False diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs index 712973ee4..a74effb92 100644 --- a/Logs/PreferredContent.hs +++ b/Logs/PreferredContent.hs @@ -125,7 +125,7 @@ makeMatcher groupmap configmap groupwantedmap u = go True True unknownMatcher :: UUID -> FileMatcher Annex unknownMatcher u = generate [present] where - present = Operation $ matchPresent (Just u) + present = Operation $ limitPresent (Just u) {- Checks if an expression can be parsed, if not returns Just error -} checkPreferredContentExpression :: PreferredContentExpression -> Maybe String |