From c72aae3c2d4b8583ceffc4cb0f35ce21f4d2aa08 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 2 Apr 2013 23:40:13 -0400 Subject: fix preferred content check for 1 semitrusted or better copy Let's make semitrusted+:1 mean that, since it cannot be expressed easily with the current syntax (could use (semitrusted:1 or trusted:1), but that does not scale to higher values than 2 copy, and also fails if I add more trust levels). Thanks to Andy for spotting this bug by just reading my blog. --- Limit.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Limit.hs') diff --git a/Limit.hs b/Limit.hs index 98227144d..1d8646bb1 100644 --- a/Limit.hs +++ b/Limit.hs @@ -145,8 +145,8 @@ addCopies = addLimit . limitCopies limitCopies :: MkLimit limitCopies want = case split ":" want of - [v, n] -> case readTrustLevel v of - Just trust -> go n $ checktrust trust + [v, n] -> case parsetrustspec v of + Just pred -> go n $ checktrust pred Nothing -> go n $ checkgroup v [n] -> go n $ const $ return True _ -> Left "bad value for copies" @@ -160,8 +160,11 @@ limitCopies want = case split ":" want of us <- filter (`S.notMember` notpresent) <$> (filterM good =<< Remote.keyLocations key) return $ length us >= n - checktrust t u = (== t) <$> lookupTrust u + checktrust pred u = pred <$> lookupTrust u checkgroup g u = S.member g <$> lookupGroups u + parsetrustspec s + | "+" `isSuffixOf` s = (>=) <$> readTrustLevel (beginning s) + | otherwise = (==) <$> readTrustLevel s {- Adds a limit to skip files not believed to be present in all - repositories in the specified group. -} -- cgit v1.2.3