api/storage_service: use ranges when handlging restore API

this change is a follow up of 787ea4b1, to modernize the code base.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#20972
This commit is contained in:
Kefu Chai
2024-10-05 20:54:11 +08:00
committed by Pavel Emelyanov
parent 946bb870f3
commit cd05f61607

View File

@@ -505,10 +505,9 @@ void set_sstables_loader(http_context& ctx, routes& r, sharded<sstables_loader>&
if (!parsed.IsArray()) {
throw httpd::bad_param_exception("mulformatted sstables in body");
}
std::vector<sstring> sstables;
for (const rjson::value& element : parsed.GetArray()) {
sstables.emplace_back(rjson::to_string_view(element));
}
auto sstables = parsed.GetArray() |
std::views::transform([] (const auto& s) { return sstring(rjson::to_string_view(s)); }) |
std::ranges::to<std::vector>();
auto task_id = co_await sst_loader.local().download_new_sstables(keyspace, table, prefix, std::move(sstables), endpoint, bucket);
co_return json::json_return_type(fmt::to_string(task_id));
});