From 5237b17193befdac87dfbeac9391e5ccad3049bb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Oct 2012 16:09:21 -0400 Subject: 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. --- Limit.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Limit.hs') diff --git a/Limit.hs b/Limit.hs index cdaadfe2d..ae77d8a5a 100644 --- a/Limit.hs +++ b/Limit.hs @@ -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 () -- cgit v1.2.3