diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-19 16:09:21 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-19 16:09:21 -0400 |
commit | 5237b17193befdac87dfbeac9391e5ccad3049bb (patch) | |
tree | a107b4120c993103a0d37668ec9e6c9f3b28041e /Limit.hs | |
parent | 5f835c769eb673b28d2d0211adfd6cbdf420b4bc (diff) |
Replace "in=" with "present" in preferred content expressions
in= was problimatic in two ways. First, it referred to a remote by name,
but preferred content expressions can be evaluated elsewhere, where that
remote doesn't exist, or a different remote has the same name. This name
lookup code could error out at runtime. Secondly, in= seemed pretty useless.
in=here did not cause content to be gotten, but it did let present content
be dropped.
present is more useful, although "not present" is unstable and should be
avoided.
Diffstat (limited to 'Limit.hs')
-rw-r--r-- | Limit.hs | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -113,6 +113,20 @@ limitIn name = Right $ \notpresent -> check $ then return False else inAnnex key +{- Limit to content that is currently present on a uuid. -} +limitPresent :: Maybe UUID -> MkLimit +limitPresent u name = Right $ const $ check $ \key -> do + hereu <- getUUID + if u == Just hereu || u == Nothing + then inAnnex key + else do + us <- Remote.keyLocations key + return $ maybe False (`elem` us) u + where + check a = lookupFile >=> handle a + handle _ Nothing = return False + handle a (Just (key, _)) = a key + {- Adds a limit to skip files not believed to have the specified number - of copies. -} addCopies :: String -> Annex () |