summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Git.hs75
1 files changed, 41 insertions, 34 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index cf7542d74..df74a769c 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -42,7 +42,8 @@ remote = RemoteType {
list :: Annex [Git.Repo]
list = do
c <- fromRepo Git.config
- mapM (tweakurl c) =<< fromRepo Git.remotes
+ rs <- mapM (tweakurl c) =<< fromRepo Git.remotes
+ catMaybes <$> mapM configread rs
where
annexurl n = "remote." ++ n ++ ".annexurl"
tweakurl c r = do
@@ -52,41 +53,47 @@ list = do
Just url -> inRepo $ \g ->
Git.Construct.remoteNamed n $
Git.Construct.fromRemoteLocation url g
+ {- It's assumed to be cheap to read the config of non-URL
+ - remotes, so this is done each time git-annex is run
+ - in a way that uses remotes.
+ - Conversely, the config of an URL remote is only read
+ - when there is no cached UUID value. -}
+ configread r = do
+ notignored <- repoNotIgnored r
+ u <- getRepoUUID r
+ r' <- case (repoCheap r, notignored, u) of
+ (_, False, _) -> return r
+ (True, _, _) -> tryGitConfigRead r
+ (False, _, NoUUID) -> tryGitConfigRead r
+ _ -> return r
+ {- A repo with a LocalUnknown location is not currently
+ - accessible, so skip it. -}
+ if Git.repoIsLocalUnknown r'
+ then return Nothing
+ else return $ Just r'
-gen :: Git.Repo -> UUID -> Maybe RemoteConfig -> Annex Remote
-gen r u _ = do
- {- It's assumed to be cheap to read the config of non-URL remotes,
- - so this is done each time git-annex is run. Conversely,
- - the config of an URL remote is only read when there is no
- - cached UUID value. -}
- let cheap = not $ Git.repoIsUrl r
- notignored <- repoNotIgnored r
- r' <- case (cheap, notignored, u) of
- (_, False, _) -> return r
- (True, _, _) -> tryGitConfigRead r
- (False, _, NoUUID) -> tryGitConfigRead r
- _ -> return r
-
- u' <- getRepoUUID r'
-
- let defcst = if cheap then cheapRemoteCost else expensiveRemoteCost
- cst <- remoteCost r' defcst
+repoCheap :: Git.Repo -> Bool
+repoCheap = not . Git.repoIsUrl
- return Remote {
- uuid = u',
- cost = cst,
- name = Git.repoDescribe r',
- storeKey = copyToRemote r',
- retrieveKeyFile = copyFromRemote r',
- retrieveKeyFileCheap = copyFromRemoteCheap r',
- removeKey = dropKey r',
- hasKey = inAnnex r',
- hasKeyCheap = cheap,
- whereisKey = Nothing,
- config = Nothing,
- repo = r',
- remotetype = remote
- }
+gen :: Git.Repo -> UUID -> Maybe RemoteConfig -> Annex Remote
+gen r u _ = new <$> remoteCost r defcst
+ where
+ defcst = if repoCheap r then cheapRemoteCost else expensiveRemoteCost
+ new cst = Remote {
+ uuid = u,
+ cost = cst,
+ name = Git.repoDescribe r,
+ storeKey = copyToRemote r,
+ retrieveKeyFile = copyFromRemote r,
+ retrieveKeyFileCheap = copyFromRemoteCheap r,
+ removeKey = dropKey r,
+ hasKey = inAnnex r,
+ hasKeyCheap = repoCheap r,
+ whereisKey = Nothing,
+ config = Nothing,
+ repo = r,
+ remotetype = remote
+ }
{- Tries to read the config for a specified remote, updates state, and
- returns the updated repo. -}