summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-12-29 16:58:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-12-29 16:58:44 -0400
commite64ffc212e394d814ab73a32f750acbccb43dd1f (patch)
treeae60f1b4d535bca39fd95b2b7a05d175b700b737
parentef85e699babd2aabdc64e048422456ac68244ef2 (diff)
support trusted repositories that are not configured as remotes
-rw-r--r--Backend/File.hs7
-rw-r--r--Command/Move.hs2
-rw-r--r--Remotes.hs26
3 files changed, 20 insertions, 15 deletions
diff --git a/Backend/File.hs b/Backend/File.hs
index 918ba4716..ee7315021 100644
--- a/Backend/File.hs
+++ b/Backend/File.hs
@@ -49,7 +49,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
+ (trusted, untrusted, _) <- Remotes.keyPossibilities key
let remotes = trusted ++ untrusted
if null remotes
then do
@@ -92,10 +92,9 @@ checkRemoveKey key numcopiesM = do
if force || numcopiesM == Just 0
then return True
else do
- (trusted, untrusted) <- Remotes.keyPossibilities key
+ (_, untrusted, have) <- Remotes.keyPossibilities key
numcopies <- getNumCopies numcopiesM
- trusteduuids <- mapM getUUID trusted
- findcopies numcopies trusteduuids untrusted []
+ findcopies numcopies have untrusted []
where
findcopies need have [] bad
| length have >= need = return True
diff --git a/Command/Move.hs b/Command/Move.hs
index 61242955e..eb223f5ab 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -110,7 +110,7 @@ toCleanup move remote key tmpfile = do
fromStart :: Bool -> SubCmdStartString
fromStart move file = isAnnexed file $ \(key, _) -> do
remote <- Remotes.commandLineRemote
- (trusted, untrusted) <- Remotes.keyPossibilities key
+ (trusted, untrusted, _) <- Remotes.keyPossibilities key
if null $ filter (\r -> Remotes.same r remote) (trusted ++ untrusted)
then return Nothing
else do
diff --git a/Remotes.hs b/Remotes.hs
index 390531550..99c0930ad 100644
--- a/Remotes.hs
+++ b/Remotes.hs
@@ -44,9 +44,15 @@ list :: [Git.Repo] -> String
list remotes = join ", " $ map Git.repoDescribe remotes
{- 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. -}
-keyPossibilities :: Key -> Annex ([Git.Repo], [Git.Repo])
+ -
+ - 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 all UUIDs that are trusted to have the key
+ - (some may not have configured remotes).
+ -}
+keyPossibilities :: Key -> Annex ([Git.Repo], [Git.Repo], [UUID])
keyPossibilities key = do
allremotes <- remotesByCost
-- To determine if a remote has a key, its UUID needs to be known.
@@ -79,19 +85,19 @@ keyPossibilities key = do
cachedUUID r = do
u <- getUUID r
return $ null u
- partition allremotes = do
+ partition remotes = do
g <- Annex.gitRepo
validuuids <- liftIO $ keyLocations g key
- alltrusted <- getTrusted
+ trusted <- getTrusted
-- get uuids trusted to have the key
-- note that validuuids is assumed to not have dups
- let validtrusted = intersect validuuids alltrusted
+ let validtrusteduuids = intersect validuuids trusted
-- remotes that match uuids that have the key
- validremotes <- reposByUUID allremotes validuuids
+ validremotes <- reposByUUID remotes validuuids
-- partition out the trusted and untrusted remotes
- trustedremotes <- reposByUUID validremotes validtrusted
- untrustedremotes <- reposWithoutUUID validremotes alltrusted
- return (trustedremotes, untrustedremotes)
+ trustedremotes <- reposByUUID validremotes validtrusteduuids
+ untrustedremotes <- reposWithoutUUID validremotes trusted
+ return (trustedremotes, untrustedremotes, validtrusteduuids)
{- Checks if a given remote has the content for a key inAnnex.
- If the remote cannot be accessed, returns a Left error.