From fbb97b7db01724f503afeec9055cc4ab1dceffde Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 24 Oct 2024 11:27:15 +0200 Subject: serve service: Set correct protocol-aware digests in responses When returning digests in responses, ensure they are of the type the remote would know. Compatible digests can be found vis the stored mappings from Git digests to bazel objects. --- src/buildtool/serve_api/serve_service/source_tree.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/buildtool/serve_api/serve_service/source_tree.hpp') diff --git a/src/buildtool/serve_api/serve_service/source_tree.hpp b/src/buildtool/serve_api/serve_service/source_tree.hpp index e46f21bf..bf3cd9ef 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.hpp +++ b/src/buildtool/serve_api/serve_service/source_tree.hpp @@ -182,6 +182,18 @@ class SourceTreeService final std::filesystem::path const& repo_path) const noexcept -> std::remove_cvref_t; + /// \brief Set the digest field of a serve response. + /// In compatible mode, this handles also the interaction with the storages + /// to recover the corresponding compatible digest from a native digest, as + /// stored in file mappings. + template + [[nodiscard]] auto SetDigestInResponse( + gsl::not_null const& response, + std::string const& object_hash, + bool is_tree, + bool from_git) const noexcept + -> std::remove_cvref_t; + /// \brief Resolves a tree from given repository with respect to symlinks. /// The resolved tree will always be placed in the Git cache. [[nodiscard]] auto ResolveContentTree( -- cgit v1.2.3