diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-17 18:27:37 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-12-19 16:37:59 +0100 |
commit | b3c863abc09f9f81150e21af2cc89d75bee98db2 (patch) | |
tree | 7159690d103f3fd4e2d95ba077fe0b6d1e33793e /src/buildtool/execution_api/local/local_cas_reader.cpp | |
parent | bd410a2557b6127d47396cd0740347e4af0766df (diff) | |
download | justbuild-b3c863abc09f9f81150e21af2cc89d75bee98db2.tar.gz |
Move functionality for staging from CAS to output paths to TreeReader
...and employ it in LocalApi.
Diffstat (limited to 'src/buildtool/execution_api/local/local_cas_reader.cpp')
-rw-r--r-- | src/buildtool/execution_api/local/local_cas_reader.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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</*kSetEpochTime=*/true, + /*kSetWritable=*/true>( + *blob_path, output, info.type); +} + auto LocalCasReader::DumpRaw(std::filesystem::path const& path, DumpCallback const& dumper) noexcept -> bool { auto closer = [](gsl::owner<FILE*> file) -> void { |