From 6cbce88a337aefe3cf2089fcbe98e006f766822d Mon Sep 17 00:00:00 2001 From: Nate Koenig Date: Tue, 9 Apr 2024 15:02:51 -0700 Subject: [PATCH] Use config.yaml file from default cache location, if it exists (#410) * Use config.yaml file from default cache location, if it exists Signed-off-by: Nate Koenig * support config.yml Signed-off-by: Nate Koenig --------- Signed-off-by: Nate Koenig --- src/ClientConfig.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ClientConfig.cc b/src/ClientConfig.cc index 1b11c76e..db7b77e6 100644 --- a/src/ClientConfig.cc +++ b/src/ClientConfig.cc @@ -218,18 +218,24 @@ ClientConfig::ClientConfig() : dataPtr(new ClientConfigPrivate) << "to set cache path. Please use [GZ_FUEL_CACHE_PATH] instead." << std::endl; } - else - { - return; - } } - if (!gz::common::isDirectory(gzFuelPath)) + if (!gzFuelPath.empty()) { - gzerr << "[" << gzFuelPath << "] is not a directory" << std::endl; - return; + if (!gz::common::isDirectory(gzFuelPath)) + gzerr << "[" << gzFuelPath << "] is not a directory" << std::endl; + else + this->SetCacheLocation(gzFuelPath); } - this->SetCacheLocation(gzFuelPath); + + std::string configYamlFile = common::joinPaths(this->CacheLocation(), + "config.yaml"); + std::string configYmlFile = common::joinPaths(this->CacheLocation(), + "config.yml"); + if (gz::common::exists(configYamlFile)) + this->LoadConfig(configYamlFile); + else if (gz::common::exists(configYmlFile)) + this->LoadConfig(configYmlFile); } //////////////////////////////////////////////////