From 8de1359bbbb3a5bd8a4a5588bacef88eb234bb7b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 9 Apr 2014 14:10:29 -0400 Subject: make git-remote-daemon ssh transport robust * Remote system might be available, and connection get lost. Should reconnect, but needs to avoid bad behavior (ie, constant reconnect attempts.) Use exponential backoff. * Detect if old system had a too old git-annex-shell, and show the user a nice message in the webapp. Required parsing error messages, so perhaps this code shoudl be removed once enough time has passed.. * Switch the protocol to using remote URI's, rather than remote names. Names change. Also avoids issues with serialization of names containing whitespace. This is nearly ready for merge into master now. I'd still like to make the ssh transport smarter about reusing ssh connection caching during git pull. This commit was sponsored by Jim Paris. --- Remote.hs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'Remote.hs') diff --git a/Remote.hs b/Remote.hs index 0f31b99b2..da33e195e 100644 --- a/Remote.hs +++ b/Remote.hs @@ -22,6 +22,7 @@ module Remote ( remoteList, gitSyncableRemote, remoteMap, + remoteMap', uuidDescriptions, byName, byNameOnly, @@ -64,9 +65,19 @@ import Git.Types (RemoteName) import qualified Git {- Map from UUIDs of Remotes to a calculated value. -} -remoteMap :: (Remote -> a) -> Annex (M.Map UUID a) -remoteMap c = M.fromList . map (\r -> (uuid r, c r)) . - filter (\r -> uuid r /= NoUUID) <$> remoteList +remoteMap :: (Remote -> v) -> Annex (M.Map UUID v) +remoteMap mkv = remoteMap' mkv mkk + where + mkk r = case uuid r of + NoUUID -> Nothing + u -> Just u + +remoteMap' :: Ord k => (Remote -> v) -> (Remote -> Maybe k) -> Annex (M.Map k v) +remoteMap' mkv mkk = M.fromList . mapMaybe mk <$> remoteList + where + mk r = case mkk r of + Nothing -> Nothing + Just k -> Just (k, mkv r) {- Map of UUIDs of remotes and their descriptions. - The names of Remotes are added to suppliment any description that has -- cgit v1.2.3