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