diff options
| author | Stefan Boberg <[email protected]> | 2025-06-11 15:50:21 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-06-11 15:50:21 +0200 |
| commit | f4c87dcb894959e32675fad9f7b7951fa5e82bb1 (patch) | |
| tree | 2f7984a3ac56053b78fb63ec2cf2e2c65bd46d9c /src/zenutil/cache | |
| parent | add warning when detecting bad segment metadata (diff) | |
| download | zen-f4c87dcb894959e32675fad9f7b7951fa5e82bb1.tar.xz zen-f4c87dcb894959e32675fad9f7b7951fa5e82bb1.zip | |
factored out IterateSegments()
Diffstat (limited to 'src/zenutil/cache')
| -rw-r--r-- | src/zenutil/cache/rpcrecording.cpp | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/src/zenutil/cache/rpcrecording.cpp b/src/zenutil/cache/rpcrecording.cpp index 1dba038ee..ac74b95f6 100644 --- a/src/zenutil/cache/rpcrecording.cpp +++ b/src/zenutil/cache/rpcrecording.cpp @@ -405,6 +405,8 @@ struct RecordedRequestsReader RecordedRequestInfo ReadRequest(uint64_t RequestIndex, IoBuffer& OutBuffer) const; private: + static std::vector<std::filesystem::path> IterateSegments(std::filesystem::path RootPath); + struct SegmentInfo { uint64_t SegmentIndex; @@ -892,6 +894,30 @@ RecordedRequestsWriter::WriteRecordingMetadata() ////////////////////////////////////////////////////////////////////////// +std::vector<std::filesystem::path> +RecordedRequestsReader::IterateSegments(std::filesystem::path RootPath) +{ + std::vector<std::filesystem::path> Paths; + + std::error_code Ec; + std::filesystem::recursive_directory_iterator DirIt(RootPath, Ec); + + if (!Ec) + { + for (auto& Dir : DirIt) + { + if (Dir.is_regular_file() && Dir.path().filename().string().ends_with("rpc_segment_info.zcb")) + { + Paths.emplace_back(Dir.path()); + } + } + } + + std::sort(begin(Paths), end(Paths)); + + return Paths; +} + uint64_t RecordedRequestsReader::BeginRead(const std::filesystem::path& BasePath, bool InMemory) { @@ -941,28 +967,6 @@ RecordedRequestsReader::BeginRead(const std::filesystem::path& BasePath, bool In uint64_t TotalRequestCount = 0; uint64_t MaxSegmentIndex = 0; - auto IterateSegments = [&](const std::filesystem::path& RootPath) { - std::vector<std::filesystem::path> Paths; - - std::error_code Ec; - std::filesystem::recursive_directory_iterator DirIt(RootPath, Ec); - - if (!Ec) - { - for (auto& Dir : DirIt) - { - if (Dir.is_regular_file() && Dir.path().filename().string().ends_with("rpc_segment_info.zcb")) - { - Paths.emplace_back(Dir.path()); - } - } - } - - std::sort(begin(Paths), end(Paths)); - - return Paths; - }; - try { auto SegmentPaths = IterateSegments(BasePath); |