Remove 'default' as initial bucket name for Sia #54
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-07-28 07:25:25 -05:00
parent 4cf339cfc4
commit c8b6d5053e
6 changed files with 29 additions and 44 deletions

View File

@@ -41,13 +41,6 @@
#include "utils/utils.hpp"
namespace {
[[nodiscard]] auto get_bucket(const repertory::sia_config &cfg) -> std::string {
if (cfg.bucket.empty()) {
return "default";
}
return cfg.bucket;
}
[[nodiscard]] auto get_last_modified(const nlohmann::json &obj)
-> std::uint64_t {
try {
@@ -119,7 +112,7 @@ auto sia_provider::create_directory_impl(const std::string &api_path,
curl::requests::http_put_file put_file{};
put_file.allow_timeout = true;
put_file.path = "/api/worker/object" + api_path + "/";
put_file.query["bucket"] = get_bucket(get_sia_config());
put_file.query["bucket"] = get_sia_config().bucket;
std::string error_data;
put_file.response_handler = [&error_data](auto &&data, long response_code) {
@@ -363,7 +356,7 @@ auto sia_provider::get_object_info(const std::string &api_path,
curl::requests::http_get get{};
get.allow_timeout = true;
get.path = "/api/bus/object" + api_path;
get.query["bucket"] = get_bucket(get_sia_config());
get.query["bucket"] = get_sia_config().bucket;
get.query["onlymetadata"] = "true";
std::string error_data;
@@ -413,7 +406,7 @@ auto sia_provider::get_object_list(const std::string &api_path,
curl::requests::http_get get{};
get.allow_timeout = true;
get.path = "/api/bus/objects" + api_path + "/";
get.query["bucket"] = get_bucket(get_sia_config());
get.query["bucket"] = get_sia_config().bucket;
if (marker.has_value()) {
get.query["limit"] = "1000";
get.query["marker"] = marker.value();
@@ -464,7 +457,7 @@ auto sia_provider::get_total_drive_space() const -> std::uint64_t {
curl::requests::http_get get{};
get.allow_timeout = true;
get.path = "/api/bus/autopilot";
get.query["bucket"] = get_bucket(get_sia_config());
get.query["bucket"] = get_sia_config().bucket;
json config_data;
std::string error_data;
@@ -581,7 +574,7 @@ auto sia_provider::is_online() const -> bool {
curl::requests::http_get get{};
get.allow_timeout = true;
get.path = "/api/bus/consensus/state";
get.query["bucket"] = get_bucket(get_sia_config());
get.query["bucket"] = get_sia_config().bucket;
std::string error_data;
json state_data;
@@ -675,7 +668,7 @@ auto sia_provider::read_file_bytes(const std::string &api_path,
try {
curl::requests::http_get get{};
get.path = "/api/worker/object" + api_path;
get.query["bucket"] = get_bucket(get_sia_config());
get.query["bucket"] = get_sia_config().bucket;
get.headers["accept"] = "application/octet-stream";
get.range = {{
offset,
@@ -741,7 +734,7 @@ auto sia_provider::remove_directory_impl(const std::string &api_path)
curl::requests::http_delete del{};
del.allow_timeout = true;
del.path = "/api/bus/object" + api_path + "/";
del.query["bucket"] = get_bucket(get_sia_config());
del.query["bucket"] = get_sia_config().bucket;
std::string error_data;
del.response_handler = [&error_data](auto &&data, long response_code) {
@@ -777,7 +770,7 @@ auto sia_provider::remove_file_impl(const std::string &api_path) -> api_error {
curl::requests::http_delete del{};
del.allow_timeout = true;
del.path = "/api/bus/object" + api_path;
del.query["bucket"] = get_bucket(get_sia_config());
del.query["bucket"] = get_sia_config().bucket;
std::string error_data;
del.response_handler = [&error_data](auto &&data, long response_code) {
@@ -815,7 +808,7 @@ auto sia_provider::rename_file(const std::string &from_api_path,
try {
curl::requests::http_post post{};
post.json = nlohmann::json({
{"bucket", get_bucket(get_sia_config())},
{"bucket", get_sia_config().bucket},
{"from", from_api_path},
{"to", to_api_path},
{"mode", "single"},
@@ -889,7 +882,7 @@ auto sia_provider::upload_file_impl(const std::string &api_path,
curl::requests::http_put_file put_file{};
put_file.path = "/api/worker/object" + api_path;
put_file.query["bucket"] = get_bucket(get_sia_config());
put_file.query["bucket"] = get_sia_config().bucket;
put_file.headers["content-type"] = "application/octet-stream";
put_file.source_path = source_path;

View File

@@ -113,14 +113,10 @@ auto main(int argc, char **argv) -> int {
if (res == exit_code::success) {
unique_id = utils::string::trim(data);
if (unique_id.empty()) {
if (prov == provider_type::sia) {
unique_id = "default";
} else {
std::cerr << "Configuration name for '"
<< app_config::get_provider_display_name(prov)
<< "' was not provided" << std::endl;
res = exit_code::invalid_syntax;
}
std::cerr << "Configuration name for '"
<< app_config::get_provider_display_name(prov)
<< "' was not provided" << std::endl;
res = exit_code::invalid_syntax;
}
}