From b3c863abc09f9f81150e21af2cc89d75bee98db2 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 17 Dec 2024 18:27:37 +0100 Subject: Move functionality for staging from CAS to output paths to TreeReader ...and employ it in LocalApi. --- src/buildtool/execution_api/local/local_cas_reader.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/buildtool/execution_api/local/local_cas_reader.cpp') diff --git a/src/buildtool/execution_api/local/local_cas_reader.cpp b/src/buildtool/execution_api/local/local_cas_reader.cpp index 5365404f..c88f5c15 100644 --- a/src/buildtool/execution_api/local/local_cas_reader.cpp +++ b/src/buildtool/execution_api/local/local_cas_reader.cpp @@ -145,6 +145,23 @@ auto LocalCasReader::DumpBlob(Artifact::ObjectInfo const& info, return path ? DumpRaw(*path, dumper) : false; } +auto LocalCasReader::StageBlobTo( + Artifact::ObjectInfo const& info, + std::filesystem::path const& output) const noexcept -> bool { + if (not IsBlobObject(info.type)) { + return false; + } + auto const blob_path = + cas_.BlobPath(info.digest, IsExecutableObject(info.type)); + if (not blob_path) { + return false; + } + return FileSystemManager::CreateDirectory(output.parent_path()) and + FileSystemManager::CopyFileAs( + *blob_path, output, info.type); +} + auto LocalCasReader::DumpRaw(std::filesystem::path const& path, DumpCallback const& dumper) noexcept -> bool { auto closer = [](gsl::owner file) -> void { -- cgit v1.2.3