summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/local/local_api.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-02-25 15:33:39 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-02-27 09:03:30 +0100
commit55519fe96d9b64c4bc99a2d108580d1d9147e5d1 (patch)
tree10e50bcc376d395a306357e056ca226a25b126c2 /src/buildtool/execution_api/local/local_api.cpp
parent0f87d4fb45d27e3f169de99bd4196ebc6eca5e33 (diff)
downloadjustbuild-55519fe96d9b64c4bc99a2d108580d1d9147e5d1.tar.gz
LocalApi: Create ArtifactBlobs from existing files
Diffstat (limited to 'src/buildtool/execution_api/local/local_api.cpp')
-rw-r--r--src/buildtool/execution_api/local/local_api.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/buildtool/execution_api/local/local_api.cpp b/src/buildtool/execution_api/local/local_api.cpp
index 92953190..6f3d48e7 100644
--- a/src/buildtool/execution_api/local/local_api.cpp
+++ b/src/buildtool/execution_api/local/local_api.cpp
@@ -153,11 +153,11 @@ auto LocalApi::RetrieveToCas(
// Collect blobs of missing artifacts from local CAS. Trees are
// processed recursively before any blob is uploaded.
std::unordered_set<ArtifactBlob> container;
+ auto const& cas = local_context_.storage->CAS();
for (auto const& info : missing) {
// Recursively process trees.
if (IsTreeObject(info->type)) {
- auto reader =
- TreeReader<LocalCasReader>{&local_context_.storage->CAS()};
+ auto reader = TreeReader<LocalCasReader>{&cas};
auto const& result = reader.ReadDirectTreeEntries(
info->digest, std::filesystem::path{});
if (not result or not RetrieveToCas(result->infos, api)) {
@@ -166,25 +166,18 @@ auto LocalApi::RetrieveToCas(
}
// Determine artifact path.
- auto const path =
+ auto path =
IsTreeObject(info->type)
- ? local_context_.storage->CAS().TreePath(info->digest)
- : local_context_.storage->CAS().BlobPath(
- info->digest, IsExecutableObject(info->type));
- if (not path) {
- return false;
- }
-
- // Read artifact content (file or symlink).
- auto content = FileSystemManager::ReadFile(*path);
- if (not content) {
+ ? cas.TreePath(info->digest)
+ : cas.BlobPath(info->digest, IsExecutableObject(info->type));
+ if (not path.has_value()) {
return false;
}
- auto blob = ArtifactBlob::FromMemory(
- local_context_.storage_config->hash_function,
- info->type,
- *std::move(content));
+ auto blob =
+ ArtifactBlob::FromFile(local_context_.storage_config->hash_function,
+ info->type,
+ *std::move(path));
if (not blob.has_value()) {
return false;
}