summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_engine/executor/executor.hpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-02-25 13:42:22 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-02-27 09:03:30 +0100
commit461312b57d3b49f92861d2c6c5e8a6b13ffa839b (patch)
treec642cd0d3379e6886d1b3847d38661e249e75d58 /src/buildtool/execution_engine/executor/executor.hpp
parenteccc7dcfb22fb9c6c42bbcd5566cd044acd1a2f3 (diff)
downloadjustbuild-461312b57d3b49f92861d2c6c5e8a6b13ffa839b.tar.gz
ArtifactBlob: Use static function for construction
Diffstat (limited to 'src/buildtool/execution_engine/executor/executor.hpp')
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index eea0336d..93cb9655 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -331,6 +331,7 @@ class ExecutorImpl {
}
// upload missing entries (blobs or trees)
+ HashFunction const hash_function{api.GetHashType()};
std::unordered_set<ArtifactBlob> container;
for (auto const& [digest, value] : missing_entries) {
auto const entry = value->second;
@@ -338,13 +339,16 @@ class ExecutorImpl {
if (not content.has_value()) {
return false;
}
+ auto blob = ArtifactBlob::FromMemory(
+ hash_function, entry->Type(), *std::move(content));
+ if (not blob.has_value()) {
+ return false;
+ }
// store and/or upload blob, taking into account the maximum
// transfer size
if (not UpdateContainerAndUpload(
&container,
- ArtifactBlob{*digest,
- std::move(*content),
- IsExecutableObject(entry->Type())},
+ *std::move(blob),
/*exception_is_fatal=*/true,
[&api](std::unordered_set<ArtifactBlob>&& blobs) {
return api.Upload(std::move(blobs),
@@ -396,9 +400,14 @@ class ExecutorImpl {
return false;
}
- return api.Upload({ArtifactBlob{info.digest,
- std::move(*content),
- IsExecutableObject(info.type)}},
+ auto blob = ArtifactBlob::FromMemory(
+ HashFunction{api.GetHashType()}, info.type, *std::move(content));
+ if (not blob.has_value()) {
+ Logger::Log(LogLevel::Error, "failed to create ArtifactBlob");
+ return false;
+ }
+
+ return api.Upload({*std::move(blob)},
/*skip_find_missing=*/true);
}
@@ -483,12 +492,14 @@ class ExecutorImpl {
if (not content.has_value()) {
return std::nullopt;
}
- HashFunction const hash_function{api.GetHashType()};
- auto digest = ArtifactDigestFactory::HashDataAs<ObjectType::File>(
- hash_function, *content);
- if (not api.Upload({ArtifactBlob{digest,
- std::move(*content),
- IsExecutableObject(*object_type)}})) {
+
+ auto blob = ArtifactBlob::FromMemory(
+ HashFunction{api.GetHashType()}, *object_type, *std::move(content));
+ if (not blob.has_value()) {
+ return std::nullopt;
+ }
+ auto digest = blob->GetDigest();
+ if (not api.Upload({*std::move(blob)})) {
return std::nullopt;
}
return Artifact::ObjectInfo{.digest = std::move(digest),