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_api.hpp | |
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_api.hpp')
-rw-r--r-- | src/buildtool/execution_api/local/local_api.hpp | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index e87c0d23..7e7bee1c 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -101,39 +101,13 @@ class LocalApi final : public IExecutionApi { return false; } - for (std::size_t i{}; i < artifacts_info.size(); ++i) { + auto const reader = + TreeReader<LocalCasReader>{&local_context_.storage->CAS()}; + for (std::size_t i = 0; i < artifacts_info.size(); ++i) { auto const& info = artifacts_info[i]; - if (IsTreeObject(info.type)) { - // read object infos from sub tree and call retrieve recursively - auto reader = - TreeReader<LocalCasReader>{&local_context_.storage->CAS()}; - auto const result = reader.RecursivelyReadTreeLeafs( - info.digest, output_paths[i]); - if (not result) { - if (git_api_ and not git_api_->RetrieveToPaths( - {info}, {output_paths[i]})) { - return false; - } - } - else if (not RetrieveToPaths(result->infos, result->paths)) { - return false; - } - } - else { - auto const blob_path = local_context_.storage->CAS().BlobPath( - info.digest, IsExecutableObject(info.type)); - if (not blob_path) { - if (git_api_ and not git_api_->RetrieveToPaths( - {info}, {output_paths[i]})) { - return false; - } - } - else if (not FileSystemManager::CreateDirectory( - output_paths[i].parent_path()) or - not FileSystemManager::CopyFileAs< - /*kSetEpochTime=*/true, - /*kSetWritable=*/true>( - *blob_path, output_paths[i], info.type)) { + if (not reader.StageTo({info}, {output_paths[i]})) { + if (not git_api_ or + not git_api_->RetrieveToPaths({info}, {output_paths[i]})) { Logger::Log(LogLevel::Error, "staging to output path {} failed.", output_paths[i].string()); |