check remote prior to mount

This commit is contained in:
2025-08-04 08:48:57 -05:00
parent ccbf64678e
commit 3e1d7e5e9b

View File

@@ -121,11 +121,32 @@ mount(std::vector<const char *> args, std::string data_directory,
<< " Drive" << std::endl;
if (prov == provider_type::remote) {
try {
constexpr const std::uint8_t retry_count{30U};
auto remote_cfg = config.get_remote_config();
remote_cfg.host_name_or_ip = remote_host;
remote_cfg.api_port = remote_port;
config.set_remote_config(remote_cfg);
std::cout << "Connecting to remote [" << remote_host << ':' << remote_port
<< "] ..." << std::flush;
auto online{false};
for (std::uint8_t retry{0U}; not online && retry < retry_count; ++retry) {
online = remote_client(config).check() == 0;
if (online) {
continue;
}
std::cout << "." << std::flush;
std::this_thread::sleep_for(1s);
}
if (not online) {
std::cerr << " failed! remote host is offline." << std::endl;
return exit_code::communication_error;
}
std::cout << " done!" << std::endl;
remote_drive drive(
config,
[&config]() -> std::unique_ptr<remote_instance> {