From 96b4474027c9dba57bb943d84e67be402175ccc8 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 9 Jul 2024 16:30:53 +0200 Subject: Use a fixed HashFunction in CreateDirectoryDigestFromTree --- src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp | 7 +++++-- src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp index 155067fd..52002c47 100644 --- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp +++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp @@ -185,8 +185,11 @@ template if (not content) { return std::nullopt; } - auto digest = ArtifactDigest::Create( - HashFunction::Instance(), *content); + + // SHA256 is used since bazel types are processed here. + HashFunction const hash_function{HashFunction::JustHash::Compatible}; + auto digest = + ArtifactDigest::Create(hash_function, *content); auto msg = CreateDirectoryNode(dir_name); msg.set_allocated_digest( diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp index 720d00d5..e8dc6da0 100644 --- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp +++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp @@ -51,8 +51,9 @@ class BazelMsgFactory { using TreeStoreFunc = std::function(std::string const&)>; - /// \brief Create Directory digest from artifact tree structure. - /// Recursively traverse entire tree and create blobs for sub-directories. + /// \brief Create Directory digest from artifact tree structure. Uses + /// compatible HashFunction for hashing. Recursively traverse entire tree + /// and create blobs for sub-directories. /// \param tree Directory tree of artifacts. /// \param resolve_links Function for resolving symlinks. /// \param process_blob Function for processing Directory blobs. -- cgit v1.2.3