From 26090ce503f40502a62d7ebabcb4ee060b28d05b Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 27 Jul 2023 13:59:11 +0200 Subject: Execution API: support fetching a single artifact to memory --- src/buildtool/execution_api/local/local_api.hpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (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 d699ad4f..e0de1598 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -31,6 +31,7 @@ #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/git/git_api.hpp" #include "src/buildtool/execution_api/local/local_action.hpp" +#include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/storage/storage.hpp" @@ -237,6 +238,27 @@ class LocalApi final : public IExecutionApi { return api->Upload(container, /*skip_find_missing=*/true); } + [[nodiscard]] auto RetrieveToMemory( + Artifact::ObjectInfo const& artifact_info) + -> std::optional override { + std::optional location{}; + if (IsTreeObject(artifact_info.type)) { + location = storage_->CAS().TreePath(artifact_info.digest); + } + else { + location = storage_->CAS().BlobPath( + artifact_info.digest, IsExecutableObject(artifact_info.type)); + } + if (not location) { + return std::nullopt; + } + auto const content = FileSystemManager::ReadFile(*location); + if (not content) { + return std::nullopt; + } + return *content; + } + [[nodiscard]] auto Upload(BlobContainer const& blobs, bool /*skip_find_missing*/) noexcept -> bool final { -- cgit v1.2.3