diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-31 23:21:16 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-31 23:21:16 -0400 |
commit | f3e4633e359d0a4afc7a0f90a89e4d276b597d84 (patch) | |
tree | 4c90c61c6ce6f09f546a5e412d8c23f82de67013 /Remotes.hs | |
parent | 0194394be61dba0324a5a99f462aa2206066771c (diff) |
refactor inAnnex remote checking to Remotes
Diffstat (limited to 'Remotes.hs')
-rw-r--r-- | Remotes.hs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Remotes.hs b/Remotes.hs index 778ad89e2..a01da7d48 100644 --- a/Remotes.hs +++ b/Remotes.hs @@ -81,14 +81,24 @@ keyPossibilities key = do - If the remote cannot be accessed, returns a Left error. -} inAnnex :: Git.Repo -> Key -> Annex (Either IOException Bool) -inAnnex remote key = do - -- the check needs to run in an Annex monad using the remote - liftIO $ ((try $ check)::IO (Either IOException Bool)) +inAnnex r key = do + if (not $ Git.repoIsUrl r) + then check local + else do + Core.showNote ("checking " ++ Git.repoDescribe r ++ "...") + check remote where - check = do - a <- Annex.new remote [] + check a = liftIO $ ((try a)::IO (Either IOException Bool)) + local = do + -- run a local check by making an Annex monad + -- using the remote + a <- Annex.new r [] (result, _) <- Annex.run a (Core.inAnnex key) return result + remote = do + -- remote check via ssh in and test + boolSystem "ssh" [Git.urlHost r, "test -e " ++ + (shellEscape $ annexLocation r key)] {- Cost Ordered list of remotes. -} remotesByCost :: Annex [Git.Repo] |