move partitioning out of keyPossibilities

And a bug fix in passing.
This commit is contained in:
Joey Hess 2011-01-26 16:44:14 -04:00
parent 7f6af79232
commit b7903eb2d1
4 changed files with 11 additions and 19 deletions

View file

@ -50,8 +50,7 @@ dummyStore _ _ = return True
- and copy it over to this one. -}
copyKeyFile :: Key -> FilePath -> Annex Bool
copyKeyFile key file = do
(trusted, untrusted, _) <- Remotes.keyPossibilities key
let remotes = trusted ++ untrusted
(remotes, _) <- Remotes.keyPossibilities key
if null remotes
then do
showNote "not available"
@ -94,9 +93,10 @@ checkRemoveKey key numcopiesM = do
if force || numcopiesM == Just 0
then return True
else do
(_, untrusted, have) <- Remotes.keyPossibilities key
(remotes, trusteduuids) <- Remotes.keyPossibilities key
untrusted <- reposWithoutUUID remotes trusteduuids
numcopies <- getNumCopies numcopiesM
findcopies numcopies have untrusted []
findcopies numcopies trusteduuids untrusted []
where
findcopies need have [] bad
| length have >= need = return True

View file

@ -110,8 +110,8 @@ toCleanup dest move key = do
fromStart :: Git.Repo -> Bool -> CommandStartString
fromStart src move file = isAnnexed file $ \(key, _) -> do
g <- Annex.gitRepo
(trusted, untrusted, _) <- Remotes.keyPossibilities key
if (g == src) || (null $ filter (\r -> Remotes.same r src) (trusted ++ untrusted))
(remotes, _) <- Remotes.keyPossibilities key
if (g == src) || (null $ filter (\r -> Remotes.same r src) remotes)
then return Nothing
else do
showAction move file

View file

@ -112,15 +112,11 @@ readConfigs = do
return $ null u
{- Cost ordered lists of remotes that the LocationLog indicate may have a key.
-
- The first list is of remotes that are trusted to have the key.
-
- The second is of untrusted remotes that may have the key.
-
- Also returns a list of UUIDs that are trusted to have the key
- (some may not have configured remotes).
-}
keyPossibilities :: Key -> Annex ([Git.Repo], [Git.Repo], [UUID])
keyPossibilities :: Key -> Annex ([Git.Repo], [UUID])
keyPossibilities key = do
readConfigs
@ -129,23 +125,17 @@ keyPossibilities key = do
u <- getUUID g
trusted <- trustGet Trusted
-- get uuids of other repositories that are
-- believed to have the key
-- get uuids of all repositories that are recorded to have the key
uuids <- liftIO $ keyLocations g key
let validuuids = filter (/= u) uuids
-- get uuids trusted to have the key
-- note that validuuids is assumed to not have dups
let validtrusteduuids = intersect validuuids trusted
-- remotes that match uuids that have the key
validremotes <- reposByUUID allremotes validuuids
-- partition out the trusted and untrusted remotes
trustedremotes <- reposByUUID validremotes validtrusteduuids
untrustedremotes <- reposWithoutUUID validremotes trusted
return (trustedremotes, untrustedremotes, validtrusteduuids)
return (validremotes, validtrusteduuids)
{- Checks if a given remote has the content for a key inAnnex.
- If the remote cannot be accessed, returns a Left error.

2
debian/changelog vendored
View file

@ -6,6 +6,8 @@ git-annex (0.19) UNRELEASED; urgency=low
* untrust: Now marks the current repository as untrusted.
* semitrust: Now restores the default trust level. (What untrust used to do.)
* fsck: Warn if content is only in untrusted repositories.
* bugfix: Files were copied from trusted remotes first even if their
annex.cost was higher than other remotes.
-- Joey Hess <joeyh@debian.org> Wed, 19 Jan 2011 18:07:51 -0400