]> dgit.raspbian.org Git - git-annex.git/commitdiff
take all repository locations into account for balancing
authorJoey Hess <joeyh@joeyh.name>
Tue, 13 Aug 2024 17:46:47 +0000 (13:46 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 13 Aug 2024 17:46:47 +0000 (13:46 -0400)
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

index 3e0bd8065423e221c5e73a5ca2f5463331f2e910..ff988561fe574773fe9be1fad1edf1bf00f17d00 100644 (file)
--- 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