summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp10
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp3
2 files changed, 13 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
index f784fd09..22416dd9 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
@@ -226,6 +226,16 @@ auto BazelNetworkReader::BatchReadBlobs(
return artifacts;
}
+auto BazelNetworkReader::Validate(ArtifactBlob const& blob) const noexcept
+ -> bool {
+ auto rehashed = blob.digest.IsTree()
+ ? ArtifactDigestFactory::HashDataAs<ObjectType::Tree>(
+ hash_function_, *blob.data)
+ : ArtifactDigestFactory::HashDataAs<ObjectType::File>(
+ hash_function_, *blob.data);
+ return rehashed == blob.digest;
+}
+
auto BazelNetworkReader::Validate(BazelBlob const& blob) const noexcept
-> std::optional<HashInfo> {
// validate digest
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp
index 0688e83d..4dc4b821 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp
@@ -100,6 +100,9 @@ class BazelNetworkReader final {
std::vector<ArtifactDigest> const& digests) const noexcept
-> std::vector<ArtifactBlob>;
+ [[nodiscard]] auto Validate(ArtifactBlob const& blob) const noexcept
+ -> bool;
+
[[nodiscard]] auto Validate(BazelBlob const& blob) const noexcept
-> std::optional<HashInfo>;
};