[bug] Incorrect file size displayed while upload is pending #23
This commit is contained in:
parent
3cbe39784f
commit
ea59ce6dc3
@ -43,8 +43,9 @@ s3_provider::s3_provider(app_config &config, i_http_comm &comm)
|
|||||||
get_comm().enable_s3_path_style(config.get_s3_config().use_path_style);
|
get_comm().enable_s3_path_style(config.get_s3_config().use_path_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::add_if_not_found(
|
auto s3_provider::add_if_not_found(api_file &file,
|
||||||
api_file &file, const std::string &object_name) const -> api_error {
|
const std::string &object_name) const
|
||||||
|
-> api_error {
|
||||||
api_meta_map meta{};
|
api_meta_map meta{};
|
||||||
if (get_item_meta(file.api_path, meta) == api_error::item_not_found) {
|
if (get_item_meta(file.api_path, meta) == api_error::item_not_found) {
|
||||||
auto err = create_path_directories(
|
auto err = create_path_directories(
|
||||||
@ -70,7 +71,7 @@ auto s3_provider::convert_api_date(std::string_view date) -> std::uint64_t {
|
|||||||
utils::string::split(date_parts.at(1U), 'Z', true).at(0U)) *
|
utils::string::split(date_parts.at(1U), 'Z', true).at(0U)) *
|
||||||
1000000UL;
|
1000000UL;
|
||||||
|
|
||||||
struct tm tm1 {};
|
struct tm tm1{};
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
utils::time::strptime(date_time.c_str(), "%Y-%m-%dT%T", &tm1);
|
||||||
return nanos + utils::time::windows_time_t_to_unix_time(_mkgmtime(&tm1));
|
return nanos + utils::time::windows_time_t_to_unix_time(_mkgmtime(&tm1));
|
||||||
@ -161,8 +162,9 @@ auto s3_provider::create_file_extra(const std::string &api_path,
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::create_path_directories(
|
auto s3_provider::create_path_directories(const std::string &api_path,
|
||||||
const std::string &api_path, const std::string &key) const -> api_error {
|
const std::string &key) const
|
||||||
|
-> api_error {
|
||||||
if (api_path == "/") {
|
if (api_path == "/") {
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
@ -295,8 +297,9 @@ auto s3_provider::get_directory_item_count(const std::string &api_path) const
|
|||||||
return 0U;
|
return 0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_directory_items_impl(
|
auto s3_provider::get_directory_items_impl(const std::string &api_path,
|
||||||
const std::string &api_path, directory_item_list &list) const -> api_error {
|
directory_item_list &list) const
|
||||||
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
const auto cfg = get_config().get_s3_config();
|
const auto cfg = get_config().get_s3_config();
|
||||||
@ -420,7 +423,14 @@ auto s3_provider::get_directory_items_impl(
|
|||||||
node.node().select_node("LastModified").node().text().as_string());
|
node.node().select_node("LastModified").node().text().as_string());
|
||||||
add_directory_item(
|
add_directory_item(
|
||||||
false, child_object_name, last_modified,
|
false, child_object_name, last_modified,
|
||||||
[&is_encrypted, &size](const directory_item &) -> std::uint64_t {
|
[&is_encrypted,
|
||||||
|
&size](const directory_item &dir_item) -> std::uint64_t {
|
||||||
|
std::string size_str{};
|
||||||
|
auto res = get_item_meta(dir_item.api_path, META_SIZE, size_str);
|
||||||
|
if (res == api_error::success && not size_str.empty()) {
|
||||||
|
return utils::string::to_uint64(size_str);
|
||||||
|
}
|
||||||
|
|
||||||
return is_encrypted ? utils::encryption::encrypting_reader::
|
return is_encrypted ? utils::encryption::encrypting_reader::
|
||||||
calculate_decrypted_size(size)
|
calculate_decrypted_size(size)
|
||||||
: size;
|
: size;
|
||||||
@ -432,8 +442,8 @@ auto s3_provider::get_directory_items_impl(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_file(const std::string &api_path,
|
auto s3_provider::get_file(const std::string &api_path, api_file &file) const
|
||||||
api_file &file) const -> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -545,8 +555,9 @@ auto s3_provider::get_file_list(api_file_list &list) const -> api_error {
|
|||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_last_modified(
|
auto s3_provider::get_last_modified(bool directory,
|
||||||
bool directory, const std::string &api_path) const -> std::uint64_t {
|
const std::string &api_path) const
|
||||||
|
-> std::uint64_t {
|
||||||
bool is_encrypted{};
|
bool is_encrypted{};
|
||||||
std::string object_name;
|
std::string object_name;
|
||||||
head_object_result result{};
|
head_object_result result{};
|
||||||
@ -556,9 +567,10 @@ auto s3_provider::get_last_modified(
|
|||||||
: utils::time::get_time_now();
|
: utils::time::get_time_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_object_info(
|
auto s3_provider::get_object_info(bool directory, const std::string &api_path,
|
||||||
bool directory, const std::string &api_path, bool &is_encrypted,
|
bool &is_encrypted, std::string &object_name,
|
||||||
std::string &object_name, head_object_result &result) const -> api_error {
|
head_object_result &result) const
|
||||||
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -607,10 +619,12 @@ auto s3_provider::get_object_info(
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_object_list(
|
auto s3_provider::get_object_list(std::string &response_data,
|
||||||
std::string &response_data, long &response_code,
|
long &response_code,
|
||||||
std::optional<std::string> delimiter, std::optional<std::string> prefix,
|
std::optional<std::string> delimiter,
|
||||||
std::optional<std::string> token) const -> bool {
|
std::optional<std::string> prefix,
|
||||||
|
std::optional<std::string> token) const
|
||||||
|
-> bool {
|
||||||
curl::requests::http_get get{};
|
curl::requests::http_get get{};
|
||||||
get.allow_timeout = true;
|
get.allow_timeout = true;
|
||||||
get.aws_service = "aws:amz:" + get_config().get_s3_config().region + ":s3";
|
get.aws_service = "aws:amz:" + get_config().get_s3_config().region + ":s3";
|
||||||
@ -689,8 +703,8 @@ auto s3_provider::get_used_drive_space_impl() const -> std::uint64_t {
|
|||||||
return total_size;
|
return total_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::is_directory(const std::string &api_path,
|
auto s3_provider::is_directory(const std::string &api_path, bool &exists) const
|
||||||
bool &exists) const -> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
exists = false;
|
exists = false;
|
||||||
@ -717,8 +731,8 @@ auto s3_provider::is_directory(const std::string &api_path,
|
|||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::is_file(const std::string &api_path,
|
auto s3_provider::is_file(const std::string &api_path, bool &exists) const
|
||||||
bool &exists) const -> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
exists = false;
|
exists = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user