clean up remote list generation to only run once
This commit is contained in:
parent
f30320aa75
commit
3470260a85
1 changed files with 14 additions and 7 deletions
21
Remote.hs
21
Remote.hs
|
@ -6,7 +6,6 @@
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Remote (
|
module Remote (
|
||||||
generate,
|
|
||||||
keyPossibilities,
|
keyPossibilities,
|
||||||
remotesWithUUID,
|
remotesWithUUID,
|
||||||
remotesWithoutUUID
|
remotesWithoutUUID
|
||||||
|
@ -27,11 +26,19 @@ import LocationLog
|
||||||
generators :: [Annex [Remote Annex]]
|
generators :: [Annex [Remote Annex]]
|
||||||
generators = [Remote.GitRemote.generate]
|
generators = [Remote.GitRemote.generate]
|
||||||
|
|
||||||
{- generates a list of all available Remotes -}
|
{- Builds a list of all available Remotes.
|
||||||
generate :: Annex [Remote Annex]
|
- Since doing so can be expensive, the list is cached in the Annex. -}
|
||||||
generate = do
|
genList :: Annex [Remote Annex]
|
||||||
lists <- sequence generators
|
genList = do
|
||||||
return $ concat lists
|
liftIO $ putStrLn "Remote.genList"
|
||||||
|
rs <- Annex.getState Annex.remotes
|
||||||
|
if null rs
|
||||||
|
then do
|
||||||
|
lists <- sequence generators
|
||||||
|
let rs' = concat lists
|
||||||
|
Annex.changeState $ \s -> s { Annex.remotes = rs' }
|
||||||
|
return rs'
|
||||||
|
else return rs
|
||||||
|
|
||||||
{- Filters a list of remotes to ones that have the listed uuids. -}
|
{- Filters a list of remotes to ones that have the listed uuids. -}
|
||||||
remotesWithUUID :: [Remote Annex] -> [UUID] -> [Remote Annex]
|
remotesWithUUID :: [Remote Annex] -> [UUID] -> [Remote Annex]
|
||||||
|
@ -60,7 +67,7 @@ keyPossibilities key = do
|
||||||
let validtrusteduuids = intersect validuuids trusted
|
let validtrusteduuids = intersect validuuids trusted
|
||||||
|
|
||||||
-- remotes that match uuids that have the key
|
-- remotes that match uuids that have the key
|
||||||
allremotes <- generate
|
allremotes <- genList
|
||||||
let validremotes = remotesWithUUID allremotes validuuids
|
let validremotes = remotesWithUUID allremotes validuuids
|
||||||
|
|
||||||
return (sort validremotes, validtrusteduuids)
|
return (sort validremotes, validtrusteduuids)
|
||||||
|
|
Loading…
Reference in a new issue