aboutsummaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-02 23:40:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-02 23:40:13 -0400
commitc72aae3c2d4b8583ceffc4cb0f35ce21f4d2aa08 (patch)
treeba50951f110604a7351bc3286bb9e6b2b8ceb427 /Limit.hs
parent6915e1f9087aa19e99552af5304c6ef86f996c0f (diff)
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.
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs9
1 files changed, 6 insertions, 3 deletions
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. -}