From be30230422b48e03e4a078399dff8e4b916f956f Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 2 Oct 2024 10:39:00 -0500 Subject: [PATCH] added error handling --- .../src/file_manager/file_manager.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index a0ba0041..5cd7b1cd 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -355,10 +355,6 @@ auto file_manager::get_stored_downloads() const -> std::vector { std::vector 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 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(), evt.get_source().get(), - "failed to remove from to upload_active table"); + "failed to remove from upload_active table"); } } else { bool exists{};