diff --git a/repertory/librepertory/src/providers/base_provider.cpp b/repertory/librepertory/src/providers/base_provider.cpp index d7e4629e..0b21c01b 100644 --- a/repertory/librepertory/src/providers/base_provider.cpp +++ b/repertory/librepertory/src/providers/base_provider.cpp @@ -19,6 +19,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #include "providers/base_provider.hpp" #include "app_config.hpp" @@ -48,8 +50,8 @@ void base_provider::add_all_items(const stop_type &stop_requested) { } auto base_provider::create_api_file(std::string path, std::string key, - std::uint64_t size, std::uint64_t file_time) - -> api_file { + std::uint64_t size, + std::uint64_t file_time) -> api_file { api_file file{}; file.api_path = utils::path::create_api_path(path); file.api_parent = utils::path::get_parent_api_path(file.api_path); @@ -81,8 +83,8 @@ auto base_provider::create_api_file(std::string path, std::uint64_t size, } auto base_provider::create_directory_clone_source_meta( - const std::string &source_api_path, const std::string &api_path) - -> api_error { + const std::string &source_api_path, + const std::string &api_path) -> api_error { REPERTORY_USES_FUNCTION_NAME(); bool exists{}; @@ -179,8 +181,8 @@ auto base_provider::create_directory(const std::string &api_path, return set_item_meta(api_path, meta); } -auto base_provider::create_file(const std::string &api_path, api_meta_map &meta) - -> api_error { +auto base_provider::create_file(const std::string &api_path, + api_meta_map &meta) -> api_error { REPERTORY_USES_FUNCTION_NAME(); bool exists{}; @@ -237,9 +239,8 @@ auto base_provider::create_file(const std::string &api_path, api_meta_map &meta) return api_error::error; } -auto base_provider::get_api_path_from_source(const std::string &source_path, - std::string &api_path) const - -> api_error { +auto base_provider::get_api_path_from_source( + const std::string &source_path, std::string &api_path) const -> api_error { REPERTORY_USES_FUNCTION_NAME(); if (source_path.empty()) { @@ -252,9 +253,8 @@ auto base_provider::get_api_path_from_source(const std::string &source_path, return db3_->get_api_path(source_path, api_path); } -auto base_provider::get_directory_items(const std::string &api_path, - directory_item_list &list) const - -> api_error { +auto base_provider::get_directory_items( + const std::string &api_path, directory_item_list &list) const -> api_error { REPERTORY_USES_FUNCTION_NAME(); bool exists{}; @@ -318,10 +318,9 @@ auto base_provider::get_file_size(const std::string &api_path, return api_error::success; } -auto base_provider::get_filesystem_item(const std::string &api_path, - bool directory, - filesystem_item &fsi) const - -> api_error { +auto base_provider::get_filesystem_item( + const std::string &api_path, bool directory, + filesystem_item &fsi) const -> api_error { bool exists{}; auto res = is_directory(api_path, exists); if (res != api_error::success) { @@ -354,10 +353,9 @@ auto base_provider::get_filesystem_item(const std::string &api_path, return api_error::success; } -auto base_provider::get_filesystem_item_and_file(const std::string &api_path, - api_file &file, - filesystem_item &fsi) const - -> api_error { +auto base_provider::get_filesystem_item_and_file( + const std::string &api_path, api_file &file, + filesystem_item &fsi) const -> api_error { auto res = get_file(api_path, file); if (res != api_error::success) { return res; @@ -416,40 +414,44 @@ auto base_provider::get_pinned_files() const -> std::vector { void base_provider::get_removed_items(std::deque &directories, std::deque &files, const stop_type &stop_requested) const { - for (auto &&api_path : db3_->get_api_path_list()) { - if (stop_requested) { - return; - } + auto list = db3_->get_api_path_list(); + std::all_of(std::execution::par, list.begin(), list.end(), + [&](auto &&api_path) -> bool { + if (stop_requested) { + return false; + } - api_meta_map meta{}; - if (get_item_meta(api_path, meta) != api_error::success) { - continue; - } + api_meta_map meta{}; + if (get_item_meta(api_path, meta) != api_error::success) { + return true; + } - if (utils::string::to_bool(meta[META_DIRECTORY])) { - bool exists{}; - if (is_directory(api_path, exists) != api_error::success) { - continue; - } + if (utils::string::to_bool(meta[META_DIRECTORY])) { + bool exists{}; + if (is_directory(api_path, exists) != api_error::success) { + return true; + } - if (not exists) { - directories.emplace_back(removed_item{api_path, true, ""}); - } + if (not exists) { + directories.emplace_back(removed_item{api_path, true, ""}); + } - continue; - } + return true; + } - bool exists{}; - if (is_file(api_path, exists) != api_error::success) { - continue; - } + bool exists{}; + if (is_file(api_path, exists) != api_error::success) { + return true; + } - if (exists) { - continue; - } + if (exists) { + return true; + } - files.emplace_back(removed_item{api_path, false, meta[META_SOURCE]}); - } + files.emplace_back( + removed_item{api_path, false, meta[META_SOURCE]}); + return true; + }); } auto base_provider::get_total_item_count() const -> std::uint64_t {