fix sizebalanced empty size bug
authorJoey Hess <joeyh@joeyh.name>
Mon, 23 Sep 2024 18:30:18 +0000 (14:30 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 23 Sep 2024 18:30:18 +0000 (14:30 -0400)
Fix bug that prevented anything being stored in an empty repository whose
preferred content expression uses sizebalanced.

CHANGELOG
Limit.hs
doc/bugs/sizebalanced_preferred_content_empty_repo_stays_empty.mdwn [new file with mode: 0644]

index 9c5ec5a91bb1750142787e4c34b57e4c36faa556..6f149158863fa29b2d759e13580beca96620a905 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,8 @@ git-annex (10.20240832) UNRELEASED; urgency=medium
   * sim: New command, can be used to simulate networks of repositories
     and see how preferred content and other configuration makes file
     content flow through it.
+  * Fix bug that prevented anything being stored in an empty
+    repository whose preferred content expression uses sizebalanced.
 
  -- Joey Hess <id@joeyh.name>  Tue, 03 Sep 2024 12:38:42 -0400
 
index 4ef4005abeda056aa19a187cc2c057691b3fdd7b..2c7ce3c22e7b39c287c2d68a53ab34377c1ddfa7 100644 (file)
--- a/Limit.hs
+++ b/Limit.hs
@@ -736,8 +736,8 @@ filterCandidatesFullySizeBalanced
 filterCandidatesFullySizeBalanced maxsizes sizemap n key candidates = do
        currentlocs <- S.fromList <$> loggedLocations key
        let keysize = fromMaybe 0 (fromKey keySize key)
-       let go u = case (M.lookup u maxsizes, M.lookup u sizemap, u `S.member` currentlocs) of
-               (Just maxsize, Just reposize, inrepo)
+       let go u = case (M.lookup u maxsizes, fromMaybe (RepoSize 0) (M.lookup u sizemap), u `S.member` currentlocs) of
+               (Just maxsize, reposize, inrepo)
                        | repoHasSpace keysize inrepo reposize maxsize ->
                                proportionfree keysize inrepo u reposize maxsize
                        | otherwise -> Nothing
diff --git a/doc/bugs/sizebalanced_preferred_content_empty_repo_stays_empty.mdwn b/doc/bugs/sizebalanced_preferred_content_empty_repo_stays_empty.mdwn
new file mode 100644 (file)
index 0000000..afbdaf8
--- /dev/null
@@ -0,0 +1,9 @@
+When using sizebalanced preferred content, a `git-annex copy --auto` to a
+repository that is currently empty will not fill it.
+
+It seems that getLiveRepoSizes returns a map that does not contain the
+repo's UUID, and filterCandidatesFullySizeBalanced filters out repos that
+are not in the map.
+--[[Joey]]
+
+> [[fixed|done]] --[[Joey]]