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
defaultNumCopies,
numCopiesCheck,
numCopiesCheck',
+ numCopiesCheck'',
numCopiesCount,
verifyEnoughCopiesToDrop,
verifiableCopies,
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
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
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
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
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.
* 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).