From b7903eb2d149ceb164d7422fb56573735d83ebde Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Jan 2011 16:44:14 -0400 Subject: move partitioning out of keyPossibilities And a bug fix in passing. --- Backend/File.hs | 8 ++++---- Command/Move.hs | 4 ++-- Remotes.hs | 16 +++------------- debian/changelog | 2 ++ 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Backend/File.hs b/Backend/File.hs index ac6e4a910..358bc4b7c 100644 --- a/Backend/File.hs +++ b/Backend/File.hs @@ -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 diff --git a/Command/Move.hs b/Command/Move.hs index d52ca07df..3eadf30c6 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -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 diff --git a/Remotes.hs b/Remotes.hs index fe5b7f767..be4c1383a 100644 --- a/Remotes.hs +++ b/Remotes.hs @@ -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. diff --git a/debian/changelog b/debian/changelog index 8b863b947..01e99ae2b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Wed, 19 Jan 2011 18:07:51 -0400 -- cgit v1.2.3