diff --git a/include/seafile/fs/seafile_store.hpp b/include/seafile/fs/seafile_store.hpp index 63847fd..a6a9a28 100644 --- a/include/seafile/fs/seafile_store.hpp +++ b/include/seafile/fs/seafile_store.hpp @@ -89,7 +89,7 @@ namespace seafile::fs tl::expected fetchAndStoreRepoDir( const std::string& repo_id, const std::string& parent_path); - std::vector queryDirectChildren( + std::vector queryDirectoryChildren( const std::string& repo_id, const std::string& parent_path); struct Database; diff --git a/src/seafile/fs/seafile_store.cpp b/src/seafile/fs/seafile_store.cpp index 14c949f..20510bf 100644 --- a/src/seafile/fs/seafile_store.cpp +++ b/src/seafile/fs/seafile_store.cpp @@ -194,19 +194,26 @@ namespace seafile::fs { tl::expected SeafileStore::checkAndSync(const std::string &repo_id) { if (!this->checkIsUpdated(repo_id)) { - std::lock_guard lock(database->mutex); - auto &storage = this->database->storage; + try { - storage.remove(sqlite_orm::where( - sqlite_orm::c(&RepoEntry::repo_id) == repo_id - ) - ); + { + std::lock_guard lock(database->mutex); + auto &storage = this->database->storage; + storage.remove_all(sqlite_orm::where( + sqlite_orm::c(&RepoEntry::repo_id) == repo_id + ) + ); + } const auto repo_entries = this->api.repoDir(repo_id, "/"); if (!repo_entries) { return tl::make_unexpected(repo_entries.error()); } - for (const auto &repo_entry: *repo_entries) { - storage.replace(RepoEntry::from_api_model(repo_id, "/", repo_entry)); + { + std::lock_guard lock(database->mutex); + auto &storage = this->database->storage; + for (const auto &repo_entry: *repo_entries) { + storage.replace(RepoEntry::from_api_model(repo_id, "/", repo_entry)); + } } } catch (std::exception &e) { return tl::make_unexpected(api::SeafileException(e.what())); @@ -258,7 +265,7 @@ namespace seafile::fs { existing = existings.at(0); } if (existing && existing->head_commit_id != storage_repo.head_commit_id) { - storage.remove(sqlite_orm::where( + storage.remove_all(sqlite_orm::where( sqlite_orm::c(&RepoEntry::repo_id) == storage_repo.id)); } storage.replace(storage_repo); @@ -311,7 +318,7 @@ namespace seafile::fs { return {}; } - std::vector SeafileStore::queryDirectChildren( + std::vector SeafileStore::queryDirectoryChildren( const std::string &repo_id, const std::string &parent_path) { std::lock_guard lock(database->mutex); auto &storage = this->database->storage; @@ -394,12 +401,12 @@ namespace seafile::fs { } const auto inner_path = joinPath(parts, 1); - auto children = queryDirectChildren(repo->id, inner_path); + auto children = queryDirectoryChildren(repo->id, inner_path); if (children.empty()) { if (const auto res = fetchAndStoreRepoDir(repo->id, inner_path); !res) { return tl::make_unexpected(res.error()); } - children = queryDirectChildren(repo->id, inner_path); + children = queryDirectoryChildren(repo->id, inner_path); } return std::variant, std::vector >(std::move(children)); }