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.
This commit is contained in:
Joey Hess 2024-08-13 13:46:47 -04:00
parent 10d8b3cc63
commit 08f55948e9
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -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