Add support for bucket name in Sia provider #16

This commit is contained in:
Scott E. Graves 2024-10-17 12:37:22 -05:00
parent bc7a74e432
commit d2ec6f1f10
3 changed files with 13 additions and 4 deletions

View File

@ -98,7 +98,7 @@ private:
std::string cache_directory_; std::string cache_directory_;
host_config hc_; host_config hc_;
s3_config s3_config_; s3_config s3_config_;
sia_config sia_config_{"default"}; sia_config sia_config_{};
std::uint64_t version_{REPERTORY_CONFIG_VERSION}; std::uint64_t version_{REPERTORY_CONFIG_VERSION};
std::string log_directory_; std::string log_directory_;
mutable std::recursive_mutex read_write_mutex_; mutable std::recursive_mutex read_write_mutex_;

View File

@ -76,7 +76,11 @@ mount(std::vector<const char *> args, std::string data_directory,
config.set_remote_host_name_or_ip(remote_host); config.set_remote_host_name_or_ip(remote_host);
config.set_remote_port(remote_port); config.set_remote_port(remote_port);
config.save(); config.save();
} else if (prov == provider_type::sia &&
config.get_sia_config().bucket.empty()) {
config.set_value_by_name("SiaConfig.Bucket", unique_id);
} }
std::cout << "Generated " << app_config::get_provider_display_name(prov) std::cout << "Generated " << app_config::get_provider_display_name(prov)
<< " Configuration" << std::endl; << " Configuration" << std::endl;
std::cout << config.get_config_file_path() << std::endl; std::cout << config.get_config_file_path() << std::endl;
@ -88,7 +92,7 @@ mount(std::vector<const char *> args, std::string data_directory,
if (utils::cli::has_option(args, utils::cli::options::hidden_option)) { if (utils::cli::has_option(args, utils::cli::options::hidden_option)) {
::ShowWindow(::GetConsoleWindow(), SW_HIDE); ::ShowWindow(::GetConsoleWindow(), SW_HIDE);
} }
#endif #endif // defined(_WIN32)
const auto drive_args = const auto drive_args =
utils::cli::parse_drive_options(args, prov, data_directory); utils::cli::parse_drive_options(args, prov, data_directory);
app_config config(prov, data_directory); app_config config(prov, data_directory);
@ -112,7 +116,7 @@ mount(std::vector<const char *> args, std::string data_directory,
return exit_code::mount_result; return exit_code::mount_result;
} }
#endif #endif // defined(_WIN32)
std::cout << "Initializing " std::cout << "Initializing "
<< app_config::get_provider_display_name(prov) << app_config::get_provider_display_name(prov)
<< (unique_id.empty() ? "" << (unique_id.empty() ? ""
@ -152,6 +156,11 @@ mount(std::vector<const char *> args, std::string data_directory,
ret = exit_code::startup_exception; ret = exit_code::startup_exception;
} }
} else { } else {
if (prov == provider_type::sia &&
config.get_sia_config().bucket.empty()) {
config.set_value_by_name("SiaConfig.Bucket", unique_id);
}
config.set_is_remote_mount(false); config.set_is_remote_mount(false);
try { try {

View File

@ -99,7 +99,7 @@ const auto DEFAULT_SIA_CONFIG = "{\n"
" \"RetryReadCount\": 6,\n" " \"RetryReadCount\": 6,\n"
" \"RingBufferFileSize\": 512,\n" " \"RingBufferFileSize\": 512,\n"
" \"SiaConfig\": {\n" " \"SiaConfig\": {\n"
" \"Bucket\": \"default\"\n" " \"Bucket\": \"\"\n"
" },\n" " },\n"
" \"Version\": " + " \"Version\": " +
std::to_string(REPERTORY_CONFIG_VERSION) + std::to_string(REPERTORY_CONFIG_VERSION) +