From 08f55948e91890aa1c4864f0e24a47639561d026 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 13 Aug 2024 13:46:47 -0400 Subject: [PATCH] take all repository locations into account for balancing This fully fixes --rebalance stability, and also deals with an issue where a file is present in each balanced repository and it didn't want to remove it from any. --- Limit.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Limit.hs b/Limit.hs index 3e0bd80654..ff988561fe 100644 --- a/Limit.hs +++ b/Limit.hs @@ -593,7 +593,7 @@ limitBalanced mu getgroupmap groupname = do limitFullyBalanced :: Maybe UUID -> Annex GroupMap -> MkLimit Annex limitFullyBalanced mu getgroupmap groupname = Right $ MatchFiles - { matchAction = \notpresent -> checkKey $ \key -> do + { matchAction = const $ checkKey $ \key -> do gm <- getgroupmap let groupmembers = fromMaybe S.empty $ M.lookup g (uuidsByGroup gm) @@ -601,9 +601,10 @@ limitFullyBalanced mu getgroupmap groupname = Right $ MatchFiles -- XXX do not calc this every time! sizemap <- calcRepoSizes let keysize = fromMaybe 0 (fromKey keySize key) + currentlocs <- S.fromList <$> loggedLocations key let hasspace u = case (M.lookup u maxsizes, M.lookup u sizemap) of (Just (MaxSize maxsize), Just (RepoSize reposize)) -> - if u `S.member` notpresent + if u `S.member` currentlocs then reposize <= maxsize else reposize + keysize <= maxsize _ -> True