clean cache directory

This commit is contained in:
Scott E. Graves 2024-09-23 20:08:35 -05:00
parent 26714a836c
commit dfb9d78448
2 changed files with 23 additions and 0 deletions

View File

@ -234,6 +234,14 @@ E_SIMPLE3(orphaned_file_processing_failed, error, true,
std::string, result, res, E_STRING
);
E_SIMPLE1(orphaned_source_file_detected, info, true,
std::string, source, src, E_STRING
);
E_SIMPLE1(orphaned_source_file_removed, info, true,
std::string, source, src, E_STRING
);
E_SIMPLE1(polling_item_begin, debug, true,
std::string, item_name, item, E_STRING
);

View File

@ -527,6 +527,21 @@ void base_provider::remove_deleted_files() {
item.api_path, item.source_path);
}
}
auto source_list =
utils::file::directory{config_.get_cache_directory()}.get_files();
for (auto &&source_file : source_list) {
filesystem_item fsi{};
if (get_filesystem_item_from_source_path(source_file->get_path(), fsi) !=
api_error::item_not_found) {
event_system::instance().raise<orphaned_source_file_detected>(
source_file->get_path());
if (source_file->remove()) {
event_system::instance().raise<orphaned_source_file_removed>(
source_file->get_path());
}
}
}
}
auto base_provider::remove_file(const std::string &api_path) -> api_error {