diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/execution_api/execution_service/bytestream_server.cpp | 5 | ||||
-rw-r--r-- | src/buildtool/execution_api/execution_service/cas_utils.cpp | 8 | ||||
-rw-r--r-- | src/buildtool/execution_api/execution_service/execution_server.cpp | 14 | ||||
-rw-r--r-- | src/buildtool/execution_api/local/local_api.hpp | 4 | ||||
-rw-r--r-- | src/buildtool/execution_api/local/local_response.hpp | 10 | ||||
-rw-r--r-- | src/buildtool/storage/local_ac.tpp | 2 | ||||
-rw-r--r-- | src/buildtool/storage/local_cas.hpp | 16 | ||||
-rw-r--r-- | src/buildtool/storage/local_cas.tpp | 10 |
8 files changed, 38 insertions, 31 deletions
diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp index 32adba91..0f77542d 100644 --- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp +++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp @@ -73,12 +73,11 @@ auto BytestreamServiceImpl::Read( if (NativeSupport::IsTree(*hash)) { ArtifactDigest dgst{NativeSupport::Unprefix(*hash), 0, true}; - path = storage_.CAS().TreePath(static_cast<bazel_re::Digest>(dgst)); + path = storage_.CAS().TreePath(dgst); } else { ArtifactDigest dgst{NativeSupport::Unprefix(*hash), 0, false}; - path = - storage_.CAS().BlobPath(static_cast<bazel_re::Digest>(dgst), false); + path = storage_.CAS().BlobPath(dgst, false); } if (not path) { auto str = fmt::format("could not find {}", *hash); diff --git a/src/buildtool/execution_api/execution_service/cas_utils.cpp b/src/buildtool/execution_api/execution_service/cas_utils.cpp index 592cd6ce..e92a2239 100644 --- a/src/buildtool/execution_api/execution_service/cas_utils.cpp +++ b/src/buildtool/execution_api/execution_service/cas_utils.cpp @@ -50,9 +50,11 @@ auto CASUtils::SplitBlobIdentity(bazel_re::Digest const& blob_digest, -> expected<std::vector<bazel_re::Digest>, grpc::Status> { // Check blob existence. - auto path = NativeSupport::IsTree(blob_digest.hash()) - ? storage.CAS().TreePath(blob_digest) - : storage.CAS().BlobPath(blob_digest, false); + auto path = + NativeSupport::IsTree(blob_digest.hash()) + ? storage.CAS().TreePath(static_cast<ArtifactDigest>(blob_digest)) + : storage.CAS().BlobPath(static_cast<ArtifactDigest>(blob_digest), + false); if (not path) { return unexpected{ grpc::Status{grpc::StatusCode::NOT_FOUND, diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp index 16202975..b862a03d 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.cpp +++ b/src/buildtool/execution_api/execution_service/execution_server.cpp @@ -378,8 +378,8 @@ namespace { if (auto error_msg = IsAHash(request.action_digest().hash())) { return unexpected{std::move(*error_msg)}; } - auto const action_path = - storage.CAS().BlobPath(request.action_digest(), false); + auto const action_path = storage.CAS().BlobPath( + static_cast<ArtifactDigest>(request.action_digest()), false); if (not action_path) { return unexpected{fmt::format("could not retrieve blob {} from cas", request.action_digest().hash())}; @@ -395,8 +395,11 @@ namespace { } auto const input_root_path = Compatibility::IsCompatible() - ? storage.CAS().BlobPath(action.input_root_digest(), false) - : storage.CAS().TreePath(action.input_root_digest()); + ? storage.CAS().BlobPath( + static_cast<ArtifactDigest>(action.input_root_digest()), + false) + : storage.CAS().TreePath( + static_cast<ArtifactDigest>(action.input_root_digest())); if (not input_root_path) { return unexpected{ @@ -412,7 +415,8 @@ namespace { if (auto error_msg = IsAHash(action.command_digest().hash())) { return unexpected{*std::move(error_msg)}; } - auto path = storage.CAS().BlobPath(action.command_digest(), false); + auto path = storage.CAS().BlobPath( + static_cast<ArtifactDigest>(action.command_digest()), false); if (not path) { return unexpected{fmt::format("Could not retrieve blob {} from cas", action.command_digest().hash())}; diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index 59dc1880..35b7b768 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -293,7 +293,9 @@ class LocalApi final : public IExecutionApi { std::vector<std::string>* targets) { targets->reserve(digests.size()); for (auto const& digest : digests) { - auto p = cas.BlobPath(digest, /*is_executable=*/false); + auto p = + cas.BlobPath(static_cast<ArtifactDigest>(digest), + /*is_executable=*/false); auto content = FileSystemManager::ReadFile(*p); targets->emplace_back(*content); } diff --git a/src/buildtool/execution_api/local/local_response.hpp b/src/buildtool/execution_api/local/local_response.hpp index 21dd5952..68ab0bcc 100644 --- a/src/buildtool/execution_api/local/local_response.hpp +++ b/src/buildtool/execution_api/local/local_response.hpp @@ -43,8 +43,9 @@ class LocalResponse final : public IExecutionResponse { return (output_.action.stdout_digest().size_bytes() != 0); } auto StdErr() noexcept -> std::string final { - if (auto path = storage_.CAS().BlobPath(output_.action.stderr_digest(), - /*is_executable=*/false)) { + if (auto path = storage_.CAS().BlobPath( + static_cast<ArtifactDigest>(output_.action.stderr_digest()), + /*is_executable=*/false)) { if (auto content = FileSystemManager::ReadFile(*path)) { return std::move(*content); } @@ -53,8 +54,9 @@ class LocalResponse final : public IExecutionResponse { return {}; } auto StdOut() noexcept -> std::string final { - if (auto path = storage_.CAS().BlobPath(output_.action.stdout_digest(), - /*is_executable=*/false)) { + if (auto path = storage_.CAS().BlobPath( + static_cast<ArtifactDigest>(output_.action.stdout_digest()), + /*is_executable=*/false)) { if (auto content = FileSystemManager::ReadFile(*path)) { return std::move(*content); } diff --git a/src/buildtool/storage/local_ac.tpp b/src/buildtool/storage/local_ac.tpp index 8ed930c4..4bd63b5c 100644 --- a/src/buildtool/storage/local_ac.tpp +++ b/src/buildtool/storage/local_ac.tpp @@ -169,7 +169,7 @@ auto LocalAC<kDoGlobalUplink>::WriteAction(bazel_re::ActionResult const& action) template <bool kDoGlobalUplink> auto LocalAC<kDoGlobalUplink>::ReadAction(bazel_re::Digest const& cas_key) const noexcept -> std::optional<bazel_re::ActionResult> { - auto const action_path = cas_.BlobPath(cas_key, + auto const action_path = cas_.BlobPath(static_cast<ArtifactDigest>(cas_key), /*is_executable=*/false); if (not action_path) { return std::nullopt; diff --git a/src/buildtool/storage/local_cas.hpp b/src/buildtool/storage/local_cas.hpp index 1b9bed48..6f3bbec1 100644 --- a/src/buildtool/storage/local_cas.hpp +++ b/src/buildtool/storage/local_cas.hpp @@ -134,7 +134,7 @@ class LocalCAS { /// \param digest Digest of the blob to lookup. /// \param is_executable Lookup blob with executable permissions. /// \returns Path to the blob if found or nullopt otherwise. - [[nodiscard]] auto BlobPath(bazel_re::Digest const& digest, + [[nodiscard]] auto BlobPath(ArtifactDigest const& digest, bool is_executable) const noexcept -> std::optional<std::filesystem::path> { auto const path = BlobPathNoSync(digest, is_executable); @@ -146,12 +146,11 @@ class LocalCAS { /// \param digest Digest of the blob to lookup. /// \param is_executable Lookup blob with executable permissions. /// \returns Path to the blob if found or nullopt otherwise. - [[nodiscard]] auto BlobPathNoSync(bazel_re::Digest const& digest, + [[nodiscard]] auto BlobPathNoSync(ArtifactDigest const& digest, bool is_executable) const noexcept -> std::optional<std::filesystem::path> { - auto const a_digest = static_cast<ArtifactDigest>(digest); - return is_executable ? cas_exec_.BlobPath(a_digest) - : cas_file_.BlobPath(a_digest); + return is_executable ? cas_exec_.BlobPath(digest) + : cas_file_.BlobPath(digest); } /// \brief Split a blob into chunks. @@ -204,10 +203,9 @@ class LocalCAS { /// \brief Obtain tree path from digest. /// \param digest Digest of the tree to lookup. /// \returns Path to the tree if found or nullopt otherwise. - [[nodiscard]] auto TreePath(bazel_re::Digest const& digest) const noexcept + [[nodiscard]] auto TreePath(ArtifactDigest const& digest) const noexcept -> std::optional<std::filesystem::path> { - auto const a_digest = static_cast<ArtifactDigest>(digest); - return cas_tree_.BlobPath(a_digest); + return cas_tree_.BlobPath(digest); } /// \brief Split a tree into chunks. @@ -350,7 +348,7 @@ class LocalCAS { /// \param digest Blob digest. /// \param to_executable Sync direction. /// \returns Path to blob in target CAS. - [[nodiscard]] auto TrySyncBlob(bazel_re::Digest const& digest, + [[nodiscard]] auto TrySyncBlob(ArtifactDigest const& digest, bool to_executable) const noexcept -> std::optional<std::filesystem::path> { auto const src_blob = BlobPathNoSync(digest, not to_executable); diff --git a/src/buildtool/storage/local_cas.tpp b/src/buildtool/storage/local_cas.tpp index bf208ca9..221470d7 100644 --- a/src/buildtool/storage/local_cas.tpp +++ b/src/buildtool/storage/local_cas.tpp @@ -48,19 +48,19 @@ auto LocalCAS<kDoGlobalUplink>::LocalUplinkBlob( bool is_executable, bool skip_sync, bool splice_result) const noexcept -> bool { + auto const a_digest = static_cast<ArtifactDigest>(digest); // Determine blob path in latest generation. - auto blob_path_latest = latest.BlobPathNoSync(digest, is_executable); + auto blob_path_latest = latest.BlobPathNoSync(a_digest, is_executable); if (blob_path_latest) { return true; } // Determine blob path of given generation. - auto blob_path = skip_sync ? BlobPathNoSync(digest, is_executable) - : BlobPath(digest, is_executable); + auto blob_path = skip_sync ? BlobPathNoSync(a_digest, is_executable) + : BlobPath(a_digest, is_executable); std::optional<LargeObject> spliced; if (not blob_path) { - spliced = - TrySplice<ObjectType::File>(static_cast<ArtifactDigest>(digest)); + spliced = TrySplice<ObjectType::File>(a_digest); blob_path = spliced ? std::optional{spliced->GetPath()} : std::nullopt; } if (not blob_path) { |