mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
Fix start clickhouse-client with unreadable working directory
This commit is contained in:
parent
a13a7f65d8
commit
955c031474
@ -10,14 +10,25 @@ namespace DB
|
||||
{
|
||||
bool configReadClient(Poco::Util::LayeredConfiguration & config, const std::string & home_path)
|
||||
{
|
||||
auto safe_exists = [](const auto & path)->bool
|
||||
{
|
||||
std::error_code ec;
|
||||
bool res = fs::exists(path, ec);
|
||||
if (ec.value() > 0)
|
||||
{
|
||||
LOG_ERROR(&Poco::Logger::get("ClickHouseClient"), "Can't check '{}': [{}]({})", path, ec.value(), ec.message());
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
std::string config_path;
|
||||
if (config.has("config-file"))
|
||||
config_path = config.getString("config-file");
|
||||
else if (fs::exists("./clickhouse-client.xml"))
|
||||
else if (safe_exists("./clickhouse-client.xml"))
|
||||
config_path = "./clickhouse-client.xml";
|
||||
else if (!home_path.empty() && fs::exists(home_path + "/.clickhouse-client/config.xml"))
|
||||
else if (!home_path.empty() && safe_exists(home_path + "/.clickhouse-client/config.xml"))
|
||||
config_path = home_path + "/.clickhouse-client/config.xml";
|
||||
else if (fs::exists("/etc/clickhouse-client/config.xml"))
|
||||
else if (safe_exists("/etc/clickhouse-client/config.xml"))
|
||||
config_path = "/etc/clickhouse-client/config.xml";
|
||||
|
||||
if (!config_path.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user