handle remove error

This commit is contained in:
2025-01-02 14:20:20 -06:00
parent 743281497c
commit 3493054f1a

View File

@ -33,6 +33,7 @@
#include "utils/file_utils.hpp" #include "utils/file_utils.hpp"
#include "utils/path.hpp" #include "utils/path.hpp"
#include "utils/polling.hpp" #include "utils/polling.hpp"
#include <utils/config.hpp>
namespace repertory { namespace repertory {
encrypt_provider::encrypt_provider(app_config &config) encrypt_provider::encrypt_provider(app_config &config)
@ -806,6 +807,8 @@ auto encrypt_provider::read_file_bytes(const std::string &api_path,
} }
void encrypt_provider::remove_deleted_files(stop_type &stop_requested) { void encrypt_provider::remove_deleted_files(stop_type &stop_requested) {
REPERTORY_USES_FUNCTION_NAME();
db_->enumerate_api_path_list( db_->enumerate_api_path_list(
[this, &stop_requested](auto &&list) { [this, &stop_requested](auto &&list) {
std::vector<i_file_db::file_info> removed_list{}; std::vector<i_file_db::file_info> removed_list{};
@ -824,16 +827,22 @@ void encrypt_provider::remove_deleted_files(stop_type &stop_requested) {
return; return;
} }
// TODO handle error auto res{db_->remove_item(item.api_path)};
auto del_res{db_->remove_item(item.api_path)}; if (res != api_error::success) {
if (item.directory) { utils::error::raise_api_path_error(
event_system::instance().raise<directory_removed_externally>( function_name, item.api_path, item.source_path, res,
item.api_path, item.source_path); fmt::format("failed to process externally removed item|dir|{}",
utils::string::from_bool(item.directory)));
continue; continue;
} }
event_system::instance().raise<file_removed_externally>( if (item.directory) {
item.api_path, item.source_path); event_system::instance().raise<directory_removed_externally>(
item.api_path, item.source_path);
} else {
event_system::instance().raise<file_removed_externally>(
item.api_path, item.source_path);
}
} }
}, },
stop_requested); stop_requested);