From e78bf2972556f49ff37a9dbc0ff3eb12ac24fdc3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 17 Jan 2020 13:32:48 -0400 Subject: [PATCH] avoid getting config parser when there is no config to parse The benefit here is that external special remotes will need a LISTCONFIGS request and response to generate their config parser, and this avoids it being done for all the ones that don't have any configs. Note that, a config parser could in theory fail to parse if there are no configs (none currently do), but a parse failure is already thrown away when generating the remote list because it's too late. Such problems have to be caught at initremote/enableremote time, not here. --- Remote/List.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Remote/List.hs b/Remote/List.hs index de30320554..9a8bd2fb3e 100644 --- a/Remote/List.hs +++ b/Remote/List.hs @@ -110,7 +110,9 @@ remoteGen m t g = do let cu = fromMaybe u $ remoteAnnexConfigUUID gc let rs = RemoteStateHandle cu let c = fromMaybe M.empty $ M.lookup cu m - pc <- either mempty id . parseRemoteConfig c <$> configParser t + pc <- if null c + then pure mempty + else either mempty id . parseRemoteConfig c <$> configParser t generate t g u pc gc rs >>= \case Nothing -> return Nothing Just r -> Just <$> adjustExportImport (adjustReadOnly (addHooks r)) rs