avoid unnecessary read of trust.log

This commit is contained in:
Joey Hess 2011-06-23 13:39:04 -04:00
parent aec4709c3f
commit 7ee636f6dd
4 changed files with 24 additions and 7 deletions

View file

@ -52,7 +52,7 @@ dummyStore _ _ = return True
- and copy it to here. -}
copyKeyFile :: Key -> FilePath -> Annex Bool
copyKeyFile key file = do
(remotes, _) <- Remote.keyPossibilities key
remotes <- Remote.keyPossibilities key
if null remotes
then do
showNote "not available"
@ -95,7 +95,7 @@ checkRemoveKey key numcopiesM = do
if force || numcopiesM == Just 0
then return True
else do
(remotes, trusteduuids) <- Remote.keyPossibilities key
(remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key
untrusteduuids <- trustGet UnTrusted
let tocheck = Remote.remotesWithoutUUID remotes (trusteduuids++untrusteduuids)
numcopies <- getNumCopies numcopiesM

View file

@ -89,7 +89,7 @@ toPerform dest move key = do
let fastcheck = fast && not move && not (Remote.hasKeyCheap dest)
isthere <- if fastcheck
then do
(remotes, _) <- Remote.keyPossibilities key
remotes <- Remote.keyPossibilities key
return $ Right $ dest `elem` remotes
else Remote.hasKey dest key
case isthere of
@ -123,7 +123,7 @@ fromStart :: Remote.Remote Annex -> Bool -> CommandStartString
fromStart src move file = isAnnexed file $ \(key, _) -> do
g <- Annex.gitRepo
u <- getUUID g
(remotes, _) <- Remote.keyPossibilities key
remotes <- Remote.keyPossibilities key
if (u == Remote.uuid src) || (null $ filter (== src) remotes)
then stop
else do

View file

@ -15,6 +15,7 @@ module Remote (
hasKey,
hasKeyCheap,
keyPossibilities,
keyPossibilitiesTrusted,
forceTrust,
remoteTypes,
@ -127,13 +128,30 @@ remotesWithUUID rs us = filter (\r -> uuid r `elem` us) rs
remotesWithoutUUID :: [Remote Annex] -> [UUID] -> [Remote Annex]
remotesWithoutUUID rs us = filter (\r -> uuid r `notElem` us) rs
{- Cost ordered lists of remotes that the LocationLog indicate may have a key.
-}
keyPossibilities :: Key -> Annex [Remote Annex]
keyPossibilities key = do
g <- Annex.gitRepo
u <- getUUID g
-- get uuids of all remotes that are recorded to have the key
uuids <- keyLocations key
let validuuids = filter (/= u) uuids
-- remotes that match uuids that have the key
allremotes <- genList
let validremotes = remotesWithUUID allremotes validuuids
return $ sort validremotes
{- Cost ordered lists of remotes that the LocationLog indicate may have a key.
-
- Also returns a list of UUIDs that are trusted to have the key
- (some may not have configured remotes).
-}
keyPossibilities :: Key -> Annex ([Remote Annex], [UUID])
keyPossibilities key = do
keyPossibilitiesTrusted :: Key -> Annex ([Remote Annex], [UUID])
keyPossibilitiesTrusted key = do
g <- Annex.gitRepo
u <- getUUID g
trusted <- trustGet Trusted

1
debian/changelog vendored
View file

@ -5,7 +5,6 @@ git-annex (3.20110611) UNRELEASED; urgency=low
* merge: New subcommand. Auto-merges the new git-annex branch.
* Improved handling of bare git repos with annexes. Many more commands will
work in them.
* Sped up many commands.
* git-annex is now more robust; it will never leave state files
uncommitted when some other git process comes along and locks the index
at an inconvenient time.