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.
This commit is contained in:
Joey Hess 2020-01-17 13:32:48 -04:00
parent 6eea31acb8
commit e78bf29725
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -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