renamed default download type
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
@ -216,33 +216,31 @@ enum class api_error {
|
||||
|
||||
[[nodiscard]] auto api_error_from_string(std::string_view str) -> api_error;
|
||||
|
||||
[[nodiscard]] auto api_error_to_string(const api_error &error)
|
||||
-> const std::string &;
|
||||
[[nodiscard]] auto
|
||||
api_error_to_string(const api_error &error) -> const std::string &;
|
||||
|
||||
enum class database_type {
|
||||
rocksdb,
|
||||
sqlite,
|
||||
};
|
||||
[[nodiscard]] auto
|
||||
database_type_from_string(std::string type,
|
||||
database_type default_type = database_type::rocksdb)
|
||||
-> database_type;
|
||||
[[nodiscard]] auto database_type_from_string(
|
||||
std::string type,
|
||||
database_type default_type = database_type::rocksdb) -> database_type;
|
||||
|
||||
[[nodiscard]] auto database_type_to_string(const database_type &type)
|
||||
-> std::string;
|
||||
[[nodiscard]] auto
|
||||
database_type_to_string(const database_type &type) -> std::string;
|
||||
|
||||
enum class download_type {
|
||||
default_,
|
||||
direct,
|
||||
fallback,
|
||||
ring_buffer,
|
||||
};
|
||||
[[nodiscard]] auto
|
||||
download_type_from_string(std::string type,
|
||||
download_type default_type = download_type::fallback)
|
||||
-> download_type;
|
||||
[[nodiscard]] auto download_type_from_string(
|
||||
std::string type,
|
||||
download_type default_type = download_type::default_) -> download_type;
|
||||
|
||||
[[nodiscard]] auto download_type_to_string(const download_type &type)
|
||||
-> std::string;
|
||||
[[nodiscard]] auto
|
||||
download_type_to_string(const download_type &type) -> std::string;
|
||||
|
||||
enum class exit_code : std::int32_t {
|
||||
success = 0,
|
||||
|
@ -80,7 +80,7 @@ app_config::app_config(const provider_type &prov,
|
||||
med_freq_interval_secs_(default_med_freq_interval_secs),
|
||||
online_check_retry_secs_(default_online_check_retry_secs),
|
||||
orphaned_file_retention_days_(default_orphaned_file_retention_days),
|
||||
preferred_download_type_(download_type::fallback),
|
||||
preferred_download_type_(download_type::default_),
|
||||
retry_read_count_(default_retry_read_count),
|
||||
ring_buffer_file_size_(default_ring_buffer_file_size),
|
||||
task_wait_ms_(default_task_wait_ms) {
|
||||
@ -1171,8 +1171,13 @@ void app_config::set_low_frequency_interval_secs(std::uint16_t value) {
|
||||
}
|
||||
|
||||
void app_config::set_max_cache_size_bytes(std::uint64_t value) {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
set_value(max_cache_size_bytes_, value);
|
||||
cache_size_mgr::instance().shrink(0U);
|
||||
auto res = cache_size_mgr::instance().shrink(0U);
|
||||
if (res != api_error::success) {
|
||||
utils::error::raise_error(function_name, res, "failed to shrink cache");
|
||||
}
|
||||
}
|
||||
|
||||
void app_config::set_max_upload_count(std::uint8_t value) {
|
||||
|
@ -387,11 +387,10 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
||||
return open(api_path, directory, ofd, handle, file, nullptr);
|
||||
}
|
||||
|
||||
auto file_manager::open(const std::string &api_path, bool directory,
|
||||
const open_file_data &ofd, std::uint64_t &handle,
|
||||
std::shared_ptr<i_open_file> &file,
|
||||
std::shared_ptr<i_closeable_open_file> closeable_file)
|
||||
-> api_error {
|
||||
auto file_manager::open(
|
||||
const std::string &api_path, bool directory, const open_file_data &ofd,
|
||||
std::uint64_t &handle, std::shared_ptr<i_open_file> &file,
|
||||
std::shared_ptr<i_closeable_open_file> closeable_file) -> api_error {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
const auto create_and_add_handle =
|
||||
@ -444,18 +443,18 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
||||
|
||||
const auto get_download_type = [&](download_type type) -> download_type {
|
||||
if (directory || fsi.size == 0U) {
|
||||
return download_type::fallback;
|
||||
return download_type::default_;
|
||||
}
|
||||
|
||||
if (type == download_type::direct) {
|
||||
return type;
|
||||
}
|
||||
|
||||
if (type == download_type::fallback) {
|
||||
if (type == download_type::default_) {
|
||||
auto free_space =
|
||||
utils::file::get_free_drive_space(config_.get_cache_directory());
|
||||
if (fsi.size < free_space) {
|
||||
return download_type::fallback;
|
||||
return download_type::default_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,7 +479,11 @@ auto file_manager::open(const std::string &api_path, bool directory,
|
||||
return download_type::direct;
|
||||
};
|
||||
|
||||
auto type = get_download_type(config_.get_preferred_download_type());
|
||||
auto preferred_type = config_.get_preferred_download_type();
|
||||
auto type = directory ? download_type::default_
|
||||
: preferred_type == download_type::default_
|
||||
? download_type::ring_buffer
|
||||
: preferred_type;
|
||||
if (not directory) {
|
||||
event_system::instance().raise<download_type_selected>(
|
||||
fsi.api_path, fsi.source_path, type);
|
||||
@ -751,8 +754,8 @@ auto file_manager::rename_directory(const std::string &from_api_path,
|
||||
}
|
||||
|
||||
auto file_manager::rename_file(const std::string &from_api_path,
|
||||
const std::string &to_api_path, bool overwrite)
|
||||
-> api_error {
|
||||
const std::string &to_api_path,
|
||||
bool overwrite) -> api_error {
|
||||
if (not provider_.is_rename_supported()) {
|
||||
return api_error::not_implemented;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "utils/string.hpp"
|
||||
|
||||
namespace repertory {
|
||||
auto database_type_from_string(std::string type, database_type default_type)
|
||||
-> database_type {
|
||||
auto database_type_from_string(std::string type,
|
||||
database_type default_type) -> database_type {
|
||||
type = utils::string::to_lower(utils::string::trim(type));
|
||||
if (type == "rocksdb") {
|
||||
return database_type::rocksdb;
|
||||
@ -50,15 +50,15 @@ auto database_type_to_string(const database_type &type) -> std::string {
|
||||
}
|
||||
}
|
||||
|
||||
auto download_type_from_string(std::string type, download_type default_type)
|
||||
-> download_type {
|
||||
auto download_type_from_string(std::string type,
|
||||
download_type default_type) -> download_type {
|
||||
type = utils::string::to_lower(utils::string::trim(type));
|
||||
if (type == "direct") {
|
||||
return download_type::direct;
|
||||
if (type == "default") {
|
||||
return download_type::default_;
|
||||
}
|
||||
|
||||
if (type == "fallback") {
|
||||
return download_type::fallback;
|
||||
if (type == "direct") {
|
||||
return download_type::direct;
|
||||
}
|
||||
|
||||
if (type == "ring_buffer") {
|
||||
@ -70,14 +70,14 @@ auto download_type_from_string(std::string type, download_type default_type)
|
||||
|
||||
auto download_type_to_string(const download_type &type) -> std::string {
|
||||
switch (type) {
|
||||
case download_type::default_:
|
||||
return "default";
|
||||
case download_type::direct:
|
||||
return "direct";
|
||||
case download_type::fallback:
|
||||
return "fallback";
|
||||
case download_type::ring_buffer:
|
||||
return "ring_buffer";
|
||||
default:
|
||||
return "fallback";
|
||||
return "default";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,9 +213,9 @@ TEST(json_serialize, can_handle_download_type) {
|
||||
EXPECT_EQ(download_type::direct, data.get<download_type>());
|
||||
EXPECT_STREQ("direct", data.get<std::string>().c_str());
|
||||
|
||||
data = download_type::fallback;
|
||||
EXPECT_EQ(download_type::fallback, data.get<download_type>());
|
||||
EXPECT_STREQ("fallback", data.get<std::string>().c_str());
|
||||
data = download_type::default_;
|
||||
EXPECT_EQ(download_type::default_, data.get<download_type>());
|
||||
EXPECT_STREQ("default", data.get<std::string>().c_str());
|
||||
|
||||
data = download_type::ring_buffer;
|
||||
EXPECT_EQ(download_type::ring_buffer, data.get<download_type>());
|
||||
@ -237,9 +237,9 @@ TEST(json_serialize, can_handle_atomic_download_type) {
|
||||
EXPECT_EQ(download_type::direct, data.get<atomic<download_type>>());
|
||||
EXPECT_STREQ("direct", data.get<std::string>().c_str());
|
||||
|
||||
data = atomic<download_type>{download_type::fallback};
|
||||
EXPECT_EQ(download_type::fallback, data.get<download_type>());
|
||||
EXPECT_STREQ("fallback", data.get<std::string>().c_str());
|
||||
data = atomic<download_type>{download_type::default_};
|
||||
EXPECT_EQ(download_type::default_, data.get<download_type>());
|
||||
EXPECT_STREQ("default", data.get<std::string>().c_str());
|
||||
|
||||
data = atomic<download_type>{download_type::ring_buffer};
|
||||
EXPECT_EQ(download_type::ring_buffer, data.get<atomic<download_type>>());
|
||||
|
Reference in New Issue
Block a user