Fix bug in numcopies handling when a repoisitory has multiple remotes that point to the same repository.

This commit is contained in:
Joey Hess 2010-12-29 16:31:25 -04:00
parent d475aac375
commit 885f7048d5
2 changed files with 19 additions and 12 deletions

View file

@ -94,26 +94,31 @@ checkRemoveKey key numcopiesM = do
else do else do
(trusted, untrusted) <- Remotes.keyPossibilities key (trusted, untrusted) <- Remotes.keyPossibilities key
numcopies <- getNumCopies numcopiesM numcopies <- getNumCopies numcopiesM
trusteduuids <- mapM getUUID trusted
if numcopies > length untrusted if numcopies > length untrusted
then notEnoughCopies numcopies (length untrusted) [] then notEnoughCopies numcopies (length untrusted) []
else findcopies numcopies (length trusted) untrusted [] else findcopies numcopies trusteduuids untrusted []
where where
findcopies need have [] bad findcopies need have [] bad
| have >= need = return True | length have >= need = return True
| otherwise = notEnoughCopies need have bad | otherwise = notEnoughCopies need (length have) bad
findcopies need have (r:rs) bad findcopies need have (r:rs) bad
| have >= need = return True | length have >= need = return True
| otherwise = do | otherwise = do
haskey <- Remotes.inAnnex r key u <- getUUID r
case haskey of if not $ elem u have
Right True -> findcopies need (have+1) rs bad then do
Right False -> findcopies need have rs bad haskey <- Remotes.inAnnex r key
Left _ -> findcopies need have rs (r:bad) case haskey of
notEnoughCopies need have bad = do Right True -> findcopies need (u:have) rs bad
Right False -> findcopies need have rs bad
Left _ -> findcopies need have rs (r:bad)
else findcopies need have rs bad
notEnoughCopies need numhave bad = do
unsafe unsafe
showLongNote $ showLongNote $
"Could only verify the existence of " ++ "Could only verify the existence of " ++
show have ++ " out of " ++ show need ++ show numhave ++ " out of " ++ show need ++
" necessary copies" " necessary copies"
showTriedRemotes bad showTriedRemotes bad
showLocations key showLocations key

2
debian/changelog vendored
View file

@ -5,6 +5,8 @@ git-annex (0.15) UNRELEASED; urgency=low
not yet supported. not yet supported.
* Add trust and untrust subcommands, to allow configuring remotes * Add trust and untrust subcommands, to allow configuring remotes
that are trusted to retain files without explicit checking. that are trusted to retain files without explicit checking.
* Fix bug in numcopies handling when a repoisitory has multiple remotes
that point to the same repository.
-- Joey Hess <joeyh@debian.org> Tue, 28 Dec 2010 13:13:20 -0400 -- Joey Hess <joeyh@debian.org> Tue, 28 Dec 2010 13:13:20 -0400