exception handling
This commit is contained in:
parent
36908f7da9
commit
45ddd528b2
@ -570,6 +570,7 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
|
|||||||
-> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
try {
|
||||||
std::string response_data;
|
std::string response_data;
|
||||||
long response_code{};
|
long response_code{};
|
||||||
if (not get_object_list(response_data, response_code, std::nullopt,
|
if (not get_object_list(response_data, response_code, std::nullopt,
|
||||||
@ -591,8 +592,10 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
|
|||||||
return api_error::comm_error;
|
return api_error::comm_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto grab_more =
|
auto grab_more = doc.select_node("/ListBucketResult/IsTruncated")
|
||||||
doc.select_node("/ListBucketResult/IsTruncated").node().text().as_bool();
|
.node()
|
||||||
|
.text()
|
||||||
|
.as_bool();
|
||||||
if (grab_more) {
|
if (grab_more) {
|
||||||
marker = doc.select_node("/ListBucketResult/NextContinuationToken")
|
marker = doc.select_node("/ListBucketResult/NextContinuationToken")
|
||||||
.node()
|
.node()
|
||||||
@ -623,8 +626,11 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
|
|||||||
file.api_path = utils::path::create_api_path(api_path);
|
file.api_path = utils::path::create_api_path(api_path);
|
||||||
file.api_parent = utils::path::get_parent_api_path(file.api_path);
|
file.api_parent = utils::path::get_parent_api_path(file.api_path);
|
||||||
file.accessed_date = file.changed_date = file.creation_date =
|
file.accessed_date = file.changed_date = file.creation_date =
|
||||||
file.modified_date = convert_api_date(
|
file.modified_date = convert_api_date(node.node()
|
||||||
node.node().select_node("LastModified").node().text().as_string());
|
.select_node("LastModified")
|
||||||
|
.node()
|
||||||
|
.text()
|
||||||
|
.as_string());
|
||||||
file.file_size =
|
file.file_size =
|
||||||
is_encrypted
|
is_encrypted
|
||||||
? utils::encryption::encrypting_reader::calculate_decrypted_size(
|
? utils::encryption::encrypting_reader::calculate_decrypted_size(
|
||||||
@ -640,6 +646,11 @@ auto s3_provider::get_file_list(api_file_list &list, std::string &marker) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return grab_more ? api_error::more_data : api_error::success;
|
return grab_more ? api_error::more_data : api_error::success;
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
utils::error::raise_error(function_name, e, "exception occurred");
|
||||||
|
}
|
||||||
|
|
||||||
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto s3_provider::get_last_modified(bool directory,
|
auto s3_provider::get_last_modified(bool directory,
|
||||||
@ -753,13 +764,13 @@ auto s3_provider::is_directory(const std::string &api_path, bool &exists) const
|
|||||||
-> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
try {
|
||||||
exists = false;
|
exists = false;
|
||||||
if (api_path == "/") {
|
if (api_path == "/") {
|
||||||
exists = true;
|
exists = true;
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
bool is_encrypted{};
|
bool is_encrypted{};
|
||||||
std::string object_name;
|
std::string object_name;
|
||||||
head_object_result result{};
|
head_object_result result{};
|
||||||
@ -781,12 +792,12 @@ auto s3_provider::is_file(const std::string &api_path, bool &exists) const
|
|||||||
-> api_error {
|
-> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
|
try {
|
||||||
exists = false;
|
exists = false;
|
||||||
if (api_path == "/") {
|
if (api_path == "/") {
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
bool is_encrypted{};
|
bool is_encrypted{};
|
||||||
std::string object_name;
|
std::string object_name;
|
||||||
head_object_result result{};
|
head_object_result result{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user