From 9c6b3d38781471250699f0b8f76e20945d4ee8fb Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 21 Jan 2025 16:34:39 +0100 Subject: local api: take git fallback seriously ... and, when asked if an artifact is available, also inspect the git cas. --- src/buildtool/execution_api/local/local_api.hpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/buildtool/execution_api/local/local_api.hpp') diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index 7e7bee1c..f554c573 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -293,21 +293,29 @@ class LocalApi final : public IExecutionApi { [[nodiscard]] auto IsAvailable(ArtifactDigest const& digest) const noexcept -> bool final { - return static_cast( + auto found = static_cast( digest.IsTree() ? local_context_.storage->CAS().TreePath(digest) : local_context_.storage->CAS().BlobPath(digest, false)); + if ((not found) and git_api_) { + if (git_api_->IsAvailable(digest)) { + auto plain_local = LocalApi(&local_context_); + auto obj_info = std::vector{}; + obj_info.push_back(Artifact::ObjectInfo{ + digest, + digest.IsTree() ? ObjectType::Tree : ObjectType::File, + false}); + found = git_api_->RetrieveToCas(obj_info, plain_local); + } + } + return found; } [[nodiscard]] auto IsAvailable(std::vector const& digests) const noexcept -> std::vector final { std::vector result; for (auto const& digest : digests) { - auto const path = - digest.IsTree() - ? local_context_.storage->CAS().TreePath(digest) - : local_context_.storage->CAS().BlobPath(digest, false); - if (not path) { + if (not IsAvailable(digest)) { result.push_back(digest); } } -- cgit v1.2.3