diff options
| author | Stefan Boberg <[email protected]> | 2022-05-20 12:42:56 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2022-05-20 12:42:56 +0200 |
| commit | 5b271be0169b842cdc3d576e48bf0ddc2f122852 (patch) | |
| tree | 16f501d2190f19a7281ce3f30365817464e146cb /zenserver/projectstore.cpp | |
| parent | Added ZEN_USE_CATCH2 define (diff) | |
| parent | fix mac compilation error (diff) | |
| download | zen-5b271be0169b842cdc3d576e48bf0ddc2f122852.tar.xz zen-5b271be0169b842cdc3d576e48bf0ddc2f122852.zip | |
Merge branch 'main' into use-catch2
Diffstat (limited to 'zenserver/projectstore.cpp')
| -rw-r--r-- | zenserver/projectstore.cpp | 53 |
1 files changed, 10 insertions, 43 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp index 617f50660..d18ae9e1a 100644 --- a/zenserver/projectstore.cpp +++ b/zenserver/projectstore.cpp @@ -804,29 +804,12 @@ ProjectStore::Project::DeleteOplog(std::string_view OplogId) void ProjectStore::Project::DiscoverOplogs() { - FileSystemTraversal Traversal; - struct Visitor : public FileSystemTraversal::TreeVisitor - { - virtual void VisitFile([[maybe_unused]] const std::filesystem::path& Parent, - [[maybe_unused]] const path_view& File, - [[maybe_unused]] uint64_t FileSize) override - { - } - - virtual bool VisitDirectory([[maybe_unused]] const std::filesystem::path& Parent, const path_view& DirectoryName) override - { - Dirs.push_back(PathToUtf8(DirectoryName)); - return false; - } - - std::vector<std::string> Dirs; - } Visit; - - Traversal.TraverseFileSystem(m_OplogStoragePath, Visit); + DirectoryContent DirContent; + GetDirectoryContent(m_OplogStoragePath, DirectoryContent::IncludeDirsFlag, DirContent); - for (const std::string& Dir : Visit.Dirs) + for (const std::filesystem::path& DirPath : DirContent.Directories) { - OpenOplog(Dir); + OpenOplog(PathToUtf8(DirPath.stem())); } } @@ -900,34 +883,18 @@ ProjectStore::BasePathForProject(std::string_view ProjectId) void ProjectStore::DiscoverProjects() { - FileSystemTraversal Traversal; - struct Visitor : public FileSystemTraversal::TreeVisitor - { - virtual void VisitFile([[maybe_unused]] const std::filesystem::path& Parent, - [[maybe_unused]] const path_view& File, - [[maybe_unused]] uint64_t FileSize) override - { - } - - virtual bool VisitDirectory([[maybe_unused]] const std::filesystem::path& Parent, const path_view& DirectoryName) override - { - Dirs.push_back(PathToUtf8(DirectoryName)); - return false; - } - - std::vector<std::string> Dirs; - } Visit; - if (!std::filesystem::exists(m_ProjectBasePath)) { return; } - Traversal.TraverseFileSystem(m_ProjectBasePath, Visit); + DirectoryContent DirContent; + GetDirectoryContent(m_ProjectBasePath, DirectoryContent::IncludeDirsFlag, DirContent); - for (const auto& Dir : Visit.Dirs) + for (const std::filesystem::path& DirPath : DirContent.Directories) { - Project* Project = OpenProject(Dir); + std::string DirName = PathToUtf8(DirPath.stem()); + Project* Project = OpenProject(DirName); if (Project) { @@ -976,7 +943,7 @@ ProjectStore::GatherReferences(GcContext& GcCtx) { Stopwatch Timer; const auto Guard = - MakeGuard([this, &Timer] { ZEN_INFO("project store gathered all references in {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs())); }); + MakeGuard([&] { ZEN_INFO("project store gathered all references in {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs())); }); DiscoverProjects(); |