refactor
This commit is contained in:
parent
b80b7b482c
commit
ceda21830f
@ -445,9 +445,8 @@ void base_provider::remove_deleted_files(bool source_only) {
|
|||||||
utils::file::directory{config_.get_cache_directory()}.get_files();
|
utils::file::directory{config_.get_cache_directory()}.get_files();
|
||||||
for (auto &&source_file : source_list) {
|
for (auto &&source_file : source_list) {
|
||||||
filesystem_item fsi{};
|
filesystem_item fsi{};
|
||||||
auto sp_res =
|
if (get_filesystem_item_from_source_path(source_file->get_path(), fsi) !=
|
||||||
get_filesystem_item_from_source_path(source_file->get_path(), fsi);
|
api_error::item_not_found) {
|
||||||
if (sp_res != api_error::item_not_found) {
|
|
||||||
continue;
|
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]});
|
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) {
|
for (auto &&item : removed_list) {
|
||||||
if (item.directory) {
|
if (item.directory) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not utils::file::file(item.source_path).exists()) {
|
if (not utils::file::file{item.source_path}.exists()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto orphaned_directory =
|
if (not utils::file::directory{orphaned_directory}.create_directory()) {
|
||||||
utils::path::combine(config_.get_data_directory(), {"orphaned"});
|
|
||||||
if (not utils::file::directory(orphaned_directory).create_directory()) {
|
|
||||||
utils::error::raise_error(
|
utils::error::raise_error(
|
||||||
function_name, std::to_string(utils::get_last_error_code()),
|
function_name, std::to_string(utils::get_last_error_code()),
|
||||||
"failed to create orphaned directory|sp|" + orphaned_directory);
|
"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) {
|
if (not online || unmount_requested) {
|
||||||
remove_deleted_files(true);
|
return false;
|
||||||
|
|
||||||
polling::instance().set_callback(
|
|
||||||
{"check_deleted", polling::frequency::low,
|
|
||||||
[this]() { remove_deleted_files(false); }});
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
void base_provider::stop() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user