From 461312b57d3b49f92861d2c6c5e8a6b13ffa839b Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 25 Feb 2025 13:42:22 +0100 Subject: ArtifactBlob: Use static function for construction --- src/buildtool/execution_api/git/git_api.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/buildtool/execution_api/git/git_api.cpp') diff --git a/src/buildtool/execution_api/git/git_api.cpp b/src/buildtool/execution_api/git/git_api.cpp index 6021a913..231e717a 100644 --- a/src/buildtool/execution_api/git/git_api.cpp +++ b/src/buildtool/execution_api/git/git_api.cpp @@ -223,19 +223,16 @@ auto GitApi::RetrieveToCas( return false; } - ArtifactDigest digest = - IsTreeObject(info->type) - ? ArtifactDigestFactory::HashDataAs( - hash_function, *content) - : ArtifactDigestFactory::HashDataAs( - hash_function, *content); + auto blob = ArtifactBlob::FromMemory( + hash_function, info->type, *std::move(content)); + if (not blob.has_value()) { + return false; + } // Collect blob and upload to remote CAS if transfer size reached. if (not UpdateContainerAndUpload( &container, - ArtifactBlob{std::move(digest), - std::move(*content), - IsExecutableObject(info->type)}, + *std::move(blob), /*exception_is_fatal=*/true, [&api](std::unordered_set&& blobs) { return api.Upload(std::move(blobs), -- cgit v1.2.3