From 8408b27d3ab64d8f95aff3c17b9dcc4c69a7cac5 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Tue, 7 Mar 2023 10:44:00 +0100 Subject: bytestream server: bugfix: if a tree is requested, look for it *only* in the tree CAS. Before this patch, after the checking in the tree cas, also the blob cas was checked leading to a NOT-FOUND error. --- .../execution_service/bytestream_server.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/buildtool/execution_api/execution_service/bytestream_server.cpp') diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp index 64d5e9eb..37bfebc6 100644 --- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp +++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp @@ -53,30 +53,28 @@ auto BytestreamServiceImpl::Read( return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, str}; } - std::optional path{}; auto lock = GarbageCollector::SharedLock(); if (!lock) { auto str = fmt::format("Could not acquire SharedLock"); logger_.Emit(LogLevel::Error, str); return grpc::Status{grpc::StatusCode::INTERNAL, str}; } + + std::optional path{}; + if (NativeSupport::IsTree(*hash)) { ArtifactDigest dgst{NativeSupport::Unprefix(*hash), 0, true}; path = storage_.TreePath(static_cast(dgst)); - if (!path) { - auto str = fmt::format("could not find {}", *hash); - logger_.Emit(LogLevel::Error, str); - return ::grpc::Status{::grpc::StatusCode::NOT_FOUND, str}; - } } - ArtifactDigest dgst{NativeSupport::Unprefix(*hash), 0, false}; - path = storage_.BlobPath(static_cast(dgst), false); + else { + ArtifactDigest dgst{NativeSupport::Unprefix(*hash), 0, false}; + path = storage_.BlobPath(static_cast(dgst), false); + } if (!path) { auto str = fmt::format("could not find {}", *hash); logger_.Emit(LogLevel::Error, str); return ::grpc::Status{::grpc::StatusCode::NOT_FOUND, str}; } - std::ifstream blob{*path}; ::google::bytestream::ReadResponse response; -- cgit v1.2.3