]> dgit.raspbian.org Git - git-annex.git/commitdiff
don't count clusters as copies, continued
authorJoey Hess <joeyh@joeyh.name>
Sun, 16 Jun 2024 19:07:48 +0000 (15:07 -0400)
committerJoey Hess <joeyh@joeyh.name>
Sun, 16 Jun 2024 19:14:53 +0000 (15:14 -0400)
Handled limitCopies, as well as everything using fromNumCopies and
fromMinCopies.

This should be everything, probably.

Note that, git-annex info displays a count of repositories, which still
includes cluster. I think that's ok. It would be possible to filter out
clusters there, but to the user they're pretty much just another
repository. The numcopies displayed by eg `git-annex info .` does not
include clusters.

Annex/Drop.hs
Annex/NumCopies.hs
Command/Drop.hs
Command/Fsck.hs
Limit.hs
doc/todo/git-annex_proxies.mdwn

index f59d6f17d6ea26abbee4ec6887db369d864bc65d..ccbc18e6e11496bff8838b3410bcd715b63e82d2 100644 (file)
@@ -58,7 +58,7 @@ handleDropsFrom locs rs reason fromhere key afile si preverified runner = do
        getcopies fs = do
                (untrusted, have) <- trustPartition UnTrusted locs
                (numcopies, mincopies) <- getSafestNumMinCopies' afile key fs
-               return (length have, numcopies, mincopies, S.fromList untrusted)
+               return (numCopiesCount have, numcopies, mincopies, S.fromList untrusted)
 
        {- Check that we have enough copies still to drop the content.
         - When the remote being dropped from is untrusted, it was not
index e8dc720b20c8bf1a15af7de4e49655e5be51de3d..4d680c8411c88ae53912abefe7d580110192d0ef 100644 (file)
@@ -20,6 +20,7 @@ module Annex.NumCopies (
        defaultNumCopies,
        numCopiesCheck,
        numCopiesCheck',
+       numCopiesCheck'',
        numCopiesCount,
        verifyEnoughCopiesToDrop,
        verifiableCopies,
@@ -199,12 +200,17 @@ numCopiesCheck file key vs = do
 
 numCopiesCheck' :: RawFilePath -> (Int -> Int -> v) -> [UUID] -> Annex v
 numCopiesCheck' file vs have = do
-       needed <- fromNumCopies . fst <$> getFileNumMinCopies file
+       needed <- fst <$> getFileNumMinCopies file
        let nhave = numCopiesCount have
        explain (ActionItemTreeFile file) $ Just $ UnquotedString $
                "has " ++ show nhave ++ " " ++ pluralCopies nhave ++ 
                ", and the configured annex.numcopies is " ++ show needed
-       return $ nhave `vs` needed
+       return $ numCopiesCheck'' have vs needed
+
+numCopiesCheck'' :: [UUID] -> (Int -> Int -> v) -> NumCopies -> v
+numCopiesCheck'' have vs needed =
+       let nhave = numCopiesCount have
+       in nhave `vs` fromNumCopies needed
 
 {- When a key is logged as present in a node of the cluster,
  - the cluster's UUID will also be in the list, but is not a
index 2fcb5d6ebb1da0b3c95eb292ad954ffec3271d7a..14702a94c0fcf16656294a34e2f5aedab81f1d8b 100644 (file)
@@ -253,7 +253,7 @@ checkDropAuto automode mremote afile key a =
                        uuid <- getUUID
                        let remoteuuid = fromMaybe uuid $ Remote.uuid <$> mremote
                        locs' <- trustExclude UnTrusted $ filter (/= remoteuuid) locs
-                       if length locs' >= fromNumCopies numcopies
+                       if numCopiesCheck'' locs' (>=) numcopies
                                then a numcopies mincopies
                                else stop
                | otherwise = a numcopies mincopies
index f08d09f89f8e3dcb6b0b548d1d27081b10d6c32e..0acb018718cd76bbcba7df381569bf48b3a21e18 100644 (file)
@@ -573,7 +573,7 @@ checkKeyNumCopies key afile numcopies = do
        locs <- loggedLocations key
        (untrustedlocations, otherlocations) <- trustPartition UnTrusted locs
        (deadlocations, safelocations) <- trustPartition DeadTrusted otherlocations
-       let present = length safelocations
+       let present = numCopiesCount safelocations
        if present < fromNumCopies numcopies
                then ifM (checkDead key)
                        ( do
index 5a343a547f8d88f17946ee5a780c70faacee8a0b..252b3dd493eaf2e1e140b8e43b67f333ba620bdc 100644 (file)
--- a/Limit.hs
+++ b/Limit.hs
@@ -408,7 +408,7 @@ limitCopies want = case splitc ':' want of
        go' n good notpresent key = do
                us <- filter (`S.notMember` notpresent)
                        <$> (filterM good =<< Remote.keyLocations key)
-               return $ length us >= n
+               return $ numCopiesCount us >= n
        checktrust checker u = checker <$> lookupTrust u
        checkgroup g u = S.member g <$> lookupGroups u
        parsetrustspec s
@@ -442,7 +442,8 @@ limitLackingCopies desc approx want = case readish want of
                                MatchingUserInfo {} -> approxNumCopies
                us <- filter (`S.notMember` notpresent)
                        <$> (trustExclude UnTrusted =<< Remote.keyLocations key)
-               return $ fromNumCopies numcopies - length us >= needed
+               let vs nhave numcopies' = numcopies' - nhave >= needed
+               return $ numCopiesCheck'' us vs numcopies
        approxNumCopies = fromMaybe defaultNumCopies <$> getGlobalNumCopies
 
 {- Match keys that are unused.
index ff317303f0441af2fa7fe78cdfa9e5d6845b75ab..78fe15361cf8f0a1b3002dbf10c422b463a144d9 100644 (file)
@@ -48,11 +48,7 @@ For June's work on [[design/passthrough_proxy]], implementation plan:
 * Omit cluster UUIDs when constructing drop proofs, since lockcontent will
   always fail on a cluster. (done)
 
-* Don't count cluster UUID as a copy. (Including in `whereis` display.)
-
-  Work in progress. fromNumCopies is sometimes used to get a
-  number that is compared with a list of UUIDs. And limitCopies doesn't
-  use numcopies machinery
+* Don't count cluster UUID as a copy. (done)
 
 * Basic proxying to special remote support (non-streaming).