summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildtool/execution_api/git/git_api.cpp48
1 files changed, 12 insertions, 36 deletions
diff --git a/src/buildtool/execution_api/git/git_api.cpp b/src/buildtool/execution_api/git/git_api.cpp
index a9373590..bd948b3f 100644
--- a/src/buildtool/execution_api/git/git_api.cpp
+++ b/src/buildtool/execution_api/git/git_api.cpp
@@ -17,6 +17,7 @@
#include <cstddef>
#include <cstdio>
#include <functional>
+#include <iterator>
#include <memory>
#include <unordered_set>
#include <utility>
@@ -197,45 +198,20 @@ auto GitApi::RetrieveToCas(
if (not tree) {
return false;
}
- std::unordered_set<ArtifactBlob> tree_deps_only_blobs;
+
+ std::vector<Artifact::ObjectInfo> subentries;
+ subentries.reserve(std::distance(tree->begin(), tree->end()));
for (auto const& [path, entry] : *tree) {
- if (entry->IsTree()) {
- auto digest = ToArtifactDigest(*entry);
- if (not digest or
- not RetrieveToCas(
- {Artifact::ObjectInfo{.digest = *std::move(digest),
- .type = entry->Type(),
- .failed = false}},
- api)) {
- return false;
- }
- }
- else {
- auto const& entry_content = entry->RawData();
- if (not entry_content) {
- return false;
- }
- auto digest =
- ArtifactDigestFactory::HashDataAs<ObjectType::File>(
- hash_function, *entry_content);
- // Collect blob and upload to remote CAS if transfer
- // size reached.
- if (not UpdateContainerAndUpload(
- &tree_deps_only_blobs,
- ArtifactBlob{std::move(digest),
- *entry_content,
- IsExecutableObject(entry->Type())},
- /*exception_is_fatal=*/true,
- [&api](std::unordered_set<ArtifactBlob>&& blobs)
- -> bool {
- return api.Upload(std::move(blobs));
- })) {
- return false;
- }
+ auto digest = ToArtifactDigest(*entry);
+ if (not digest.has_value()) {
+ return false;
}
+ subentries.push_back(
+ Artifact::ObjectInfo{.digest = *std::move(digest),
+ .type = entry->Type(),
+ .failed = false});
}
- // Upload remaining blobs.
- if (not api.Upload(std::move(tree_deps_only_blobs))) {
+ if (not RetrieveToCas(subentries, api)) {
return false;
}
content = tree->RawData();