Compare commits

..

No commits in common. "8d2024d34b63483ce02d3c6b62cac7b8214637c3" and "98edf33be46c08686cc67efd3b0242315b887e27" have entirely different histories.

3 changed files with 15 additions and 50 deletions

View File

@ -54,13 +54,12 @@ REPERTORY_IGNORE_WARNINGS_DISABLE()
using namespace std::chrono_literals;
using json = nlohmann::json;
inline constexpr const std::string_view REPERTORY{"repertory"};
inline constexpr const std::string_view REPERTORY_DATA_NAME{"repertory2"};
inline constexpr const std::wstring_view REPERTORY_W{L"repertory"};
inline constexpr const std::string_view REPERTORY = "repertory";
inline constexpr const std::wstring_view REPERTORY_W = L"repertory";
inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION{2ULL};
inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION{"2.0.0"};
inline constexpr const std::string_view RENTERD_MIN_VERSION{"2.0.0"};
inline constexpr const std::uint64_t REPERTORY_CONFIG_VERSION = 2ULL;
inline constexpr const std::string_view REPERTORY_DATA_NAME = "repertory2";
inline constexpr const std::string_view REPERTORY_MIN_REMOTE_VERSION = "2.0.0";
#define REPERTORY_INVALID_HANDLE INVALID_HANDLE_VALUE

View File

@ -52,9 +52,6 @@ private:
[[nodiscard]] auto create_directory_key(const std::string &api_path) const
-> repertory::api_error;
[[nodiscard]] auto ensure_directory_exists(const std::string &api_path) const
-> api_error;
[[nodiscard]] auto get_object_info(const std::string &api_path,
json &object_info) const -> api_error;

View File

@ -67,7 +67,7 @@ auto sia_provider::check_version(std::string &required_version,
std::string &returned_version) const -> bool {
REPERTORY_USES_FUNCTION_NAME();
required_version = RENTERD_MIN_VERSION;
required_version = "2.0.0";
try {
curl::requests::http_get get{};
@ -159,14 +159,14 @@ auto sia_provider::create_directory_key(const std::string &api_path) const
}
if (not object_list.contains("objects")) {
return api_error::directory_not_found;
return api_error::item_not_found;
}
const auto &list = object_list.at("objects");
if (std::ranges::find_if(list, [&api_path](auto &&entry) -> bool {
return entry.at("key").template get<std::string>() == api_path + '/';
}) == list.end()) {
return api_error::directory_not_found;
return api_error::item_not_found;
}
api_meta_map meta;
@ -174,27 +174,6 @@ auto sia_provider::create_directory_key(const std::string &api_path) const
meta);
}
auto sia_provider::ensure_directory_exists(const std::string &api_path) const
-> api_error {
REPERTORY_USES_FUNCTION_NAME();
bool exists{};
auto res{is_directory(api_path, exists)};
if (res != api_error::success) {
utils::error::raise_api_path_error(function_name, api_path, res,
"failed detect existing directory");
return res;
}
if (not exists) {
utils::error::raise_api_path_error(function_name, api_path, res,
"directory not found");
return api_error::directory_not_found;
}
return api_error::success;
}
auto sia_provider::get_directory_item_count(const std::string &api_path) const
-> std::uint64_t {
REPERTORY_USES_FUNCTION_NAME();
@ -261,18 +240,7 @@ auto sia_provider::get_directory_items_impl(const std::string &api_path,
directory ? 0U
: entry["size"].get<std::uint64_t>(),
get_last_modified(entry));
if (directory) {
auto res{ensure_directory_exists(entry_api_path)};
if (res != api_error::success) {
utils::error::raise_api_path_error(
function_name, entry_api_path, res,
"failed detect existing directory");
continue;
}
}
get_api_item_added()(directory, file);
auto res{get_item_meta(entry_api_path, meta)};
if (res != api_error::success) {
utils::error::raise_api_path_error(function_name, entry_api_path,
@ -378,14 +346,16 @@ auto sia_provider::get_file_list(api_file_list &list,
get_last_modified(entry)),
};
auto res{ensure_directory_exists(entry_api_path)};
bool exists{};
auto res{is_directory(entry_api_path, exists)};
if (res != api_error::success) {
utils::error::raise_api_path_error(
function_name, entry_api_path, res,
"failed detect existing directory");
return res;
}
if (not exists) {
return api_error::directory_not_found;
}
get_api_item_added()(true, dir);
}
@ -585,8 +555,7 @@ auto sia_provider::is_directory(const std::string &api_path, bool &exists) const
}
}
if (res == api_error::directory_not_found ||
res == api_error::item_not_found) {
if (res == api_error::item_not_found) {
return api_error::success;
}