added error handling

This commit is contained in:
Scott E. Graves 2024-10-02 10:39:00 -05:00
parent a523d1ca66
commit be30230422

View File

@ -355,10 +355,6 @@ auto file_manager::get_stored_downloads() const -> std::vector<json> {
std::vector<json> ret;
if (not provider_.is_direct_only()) {
auto result = db::db_select{*db_.get(), resume_table}.go();
if (not result.ok()) {
return ret;
}
while (result.has_row()) {
try {
std::optional<db::db_select::row> row;
@ -570,6 +566,10 @@ auto file_manager::remove_file(const std::string &api_path) -> api_error {
.where("api_path")
.equals(api_path)
.go();
if (not result.ok()) {
utils::error::raise_api_path_error(function_name, to_api_path,
"failed to remove from resume table");
}
res = provider_.remove_file(api_path);
if (res != api_error::success) {
@ -615,11 +615,20 @@ void file_manager::remove_upload(const std::string &api_path, bool no_lock) {
.where("api_path")
.equals(api_path)
.go();
if (not result.ok()) {
utils::error::raise_api_path_error(function_name, to_api_path,
"failed to remove from upload table");
}
result = db::db_delete{*db_.get(), upload_active_table}
.where("api_path")
.equals(api_path)
.go();
if (not result.ok()) {
utils::error::raise_api_path_error(
function_name, to_api_path,
"failed to remove from upload_active table");
}
if (upload_lookup_.find(api_path) != upload_lookup_.end()) {
upload_lookup_.at(api_path)->cancel();
@ -981,6 +990,10 @@ void file_manager::swap_renamed_items(std::string from_api_path,
.where("api_path")
.equals(from_api_path)
.go();
if (not result.ok()) {
utils::error::raise_api_path_error(function_name, to_api_path,
"failed to remove from resume table");
}
}
void file_manager::upload_completed(const file_upload_completed &evt) {
@ -1001,7 +1014,7 @@ void file_manager::upload_completed(const file_upload_completed &evt) {
utils::error::raise_api_path_error(
function_name, evt.get_api_path().get<std::string>(),
evt.get_source().get<std::string>(),
"failed to remove from to upload_active table");
"failed to remove from upload_active table");
}
} else {
bool exists{};