This commit is contained in:
Scott E. Graves 2024-09-24 07:30:18 -05:00
parent b80b7b482c
commit ceda21830f

View File

@ -445,9 +445,8 @@ void base_provider::remove_deleted_files(bool source_only) {
utils::file::directory{config_.get_cache_directory()}.get_files();
for (auto &&source_file : source_list) {
filesystem_item fsi{};
auto sp_res =
get_filesystem_item_from_source_path(source_file->get_path(), fsi);
if (sp_res != api_error::item_not_found) {
if (get_filesystem_item_from_source_path(source_file->get_path(), fsi) !=
api_error::item_not_found) {
continue;
}
@ -527,18 +526,19 @@ void base_provider::remove_deleted_files(bool source_only) {
removed_list.emplace_back(removed_item{api_path, false, meta[META_SOURCE]});
}
const auto orphaned_directory =
utils::path::combine(config_.get_data_directory(), {"orphaned"});
for (auto &&item : removed_list) {
if (item.directory) {
continue;
}
if (not utils::file::file(item.source_path).exists()) {
if (not utils::file::file{item.source_path}.exists()) {
continue;
}
const auto orphaned_directory =
utils::path::combine(config_.get_data_directory(), {"orphaned"});
if (not utils::file::directory(orphaned_directory).create_directory()) {
if (not utils::file::directory{orphaned_directory}.create_directory()) {
utils::error::raise_error(
function_name, std::to_string(utils::get_last_error_code()),
"failed to create orphaned directory|sp|" + orphaned_directory);
@ -714,16 +714,15 @@ auto base_provider::start(api_item_added_callback api_item_added,
}
}
if (online && not unmount_requested) {
remove_deleted_files(true);
polling::instance().set_callback(
{"check_deleted", polling::frequency::low,
[this]() { remove_deleted_files(false); }});
return true;
if (not online || unmount_requested) {
return false;
}
return false;
remove_deleted_files(true);
polling::instance().set_callback({"check_deleted", polling::frequency::low,
[this]() { remove_deleted_files(false); }});
return true;
}
void base_provider::stop() {