diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-10-24 11:27:15 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-10-25 13:00:43 +0200 |
commit | fbb97b7db01724f503afeec9055cc4ab1dceffde (patch) | |
tree | 172fa5252fb98e34e37bc628b534140d5c1bfbd9 /src/buildtool/serve_api/serve_service/source_tree.hpp | |
parent | 56b367d4104b2476d9aa2027c8a28d0dc5ba4f2d (diff) | |
download | justbuild-fbb97b7db01724f503afeec9055cc4ab1dceffde.tar.gz |
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.
Diffstat (limited to 'src/buildtool/serve_api/serve_service/source_tree.hpp')
-rw-r--r-- | src/buildtool/serve_api/serve_service/source_tree.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
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<decltype(TResponse::OK)>; + /// \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 <typename TResponse> + [[nodiscard]] auto SetDigestInResponse( + gsl::not_null<TResponse*> const& response, + std::string const& object_hash, + bool is_tree, + bool from_git) const noexcept + -> std::remove_cvref_t<decltype(TResponse::OK)>; + /// \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( |