aboutsummaryrefslogtreecommitdiff
path: root/src/zenremotestore/chunking
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-10-15 23:51:45 +0200
committerGitHub Enterprise <[email protected]>2025-10-15 23:51:45 +0200
commit1fb15b0c9dc0ab4b84a6db8bf900b9c1c3578070 (patch)
tree6606a02cea0780427233ef975689ff8ecd81d06e /src/zenremotestore/chunking
parentadded separate xmake.lua for thirdparty (#578) (diff)
downloadzen-1fb15b0c9dc0ab4b84a6db8bf900b9c1c3578070.tar.xz
zen-1fb15b0c9dc0ab4b84a6db8bf900b9c1c3578070.zip
move builds state functions to buildsavedstate.h/cpp (#577)
Diffstat (limited to 'src/zenremotestore/chunking')
-rw-r--r--src/zenremotestore/chunking/chunkedcontent.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/zenremotestore/chunking/chunkedcontent.cpp b/src/zenremotestore/chunking/chunkedcontent.cpp
index 9df7725db..eb0e8bdc9 100644
--- a/src/zenremotestore/chunking/chunkedcontent.cpp
+++ b/src/zenremotestore/chunking/chunkedcontent.cpp
@@ -755,6 +755,50 @@ DeletePathsFromChunkedContent(const ChunkedFolderContent& BaseContent, std::span
return DeletePathsFromChunkedContent(BaseContent, BaseLookup, DeletedPaths);
}
+bool
+CompareChunkedContent(const ChunkedFolderContent& Lhs, const ChunkedFolderContent& Rhs)
+{
+ tsl::robin_map<std::string, size_t> RhsPathToIndex;
+ const size_t RhsPathCount = Rhs.Paths.size();
+ RhsPathToIndex.reserve(RhsPathCount);
+ for (size_t RhsPathIndex = 0; RhsPathIndex < RhsPathCount; RhsPathIndex++)
+ {
+ RhsPathToIndex.insert({Rhs.Paths[RhsPathIndex].generic_string(), RhsPathIndex});
+ }
+ const size_t LhsPathCount = Lhs.Paths.size();
+ for (size_t LhsPathIndex = 0; LhsPathIndex < LhsPathCount; LhsPathIndex++)
+ {
+ if (auto It = RhsPathToIndex.find(Lhs.Paths[LhsPathIndex].generic_string()); It != RhsPathToIndex.end())
+ {
+ const size_t RhsPathIndex = It->second;
+ if ((Lhs.RawHashes[LhsPathIndex] != Rhs.RawHashes[RhsPathIndex]) ||
+ (!FolderContent::AreFileAttributesEqual(Lhs.Attributes[LhsPathIndex], Rhs.Attributes[RhsPathIndex])))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ tsl::robin_set<std::string> LhsPathExists;
+ LhsPathExists.reserve(LhsPathCount);
+ for (size_t LhsPathIndex = 0; LhsPathIndex < LhsPathCount; LhsPathIndex++)
+ {
+ LhsPathExists.insert({Lhs.Paths[LhsPathIndex].generic_string()});
+ }
+ for (size_t RhsPathIndex = 0; RhsPathIndex < RhsPathCount; RhsPathIndex++)
+ {
+ if (!LhsPathExists.contains(Rhs.Paths[RhsPathIndex].generic_string()))
+ {
+ return false;
+ }
+ }
+
+ return true;
+};
+
ChunkedFolderContent
ChunkFolderContent(ChunkingStatistics& Stats,
WorkerThreadPool& WorkerPool,