support trusted repositories that are not configured as remotes
This commit is contained in:
parent
ef85e699ba
commit
e64ffc212e
3 changed files with 20 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
26
Remotes.hs
26
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.
|
||||
|
|
Loading…
Reference in a new issue