summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/local/local_cas_reader.cpp6
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp2
-rw-r--r--src/buildtool/file_system/TARGETS3
-rw-r--r--src/buildtool/file_system/git_repo.cpp22
-rw-r--r--src/buildtool/file_system/git_repo.hpp4
-rw-r--r--src/buildtool/file_system/git_tree.cpp7
-rw-r--r--src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp4
-rw-r--r--src/buildtool/storage/local_cas.tpp2
8 files changed, 23 insertions, 27 deletions
diff --git a/src/buildtool/execution_api/local/local_cas_reader.cpp b/src/buildtool/execution_api/local/local_cas_reader.cpp
index 56915fa9..3e5ebe7b 100644
--- a/src/buildtool/execution_api/local/local_cas_reader.cpp
+++ b/src/buildtool/execution_api/local/local_cas_reader.cpp
@@ -87,10 +87,10 @@ auto LocalCasReader::ReadGitTree(ArtifactDigest const& digest) const noexcept
if (auto const path = cas_.TreePath(digest)) {
if (auto const content = FileSystemManager::ReadFile(*path)) {
auto check_symlinks =
- [this](std::vector<bazel_re::Digest> const& ids) {
+ [&cas = cas_](std::vector<ArtifactDigest> const& ids) {
for (auto const& id : ids) {
- auto link_path = cas_.BlobPath(id,
- /*is_executable=*/false);
+ auto link_path = cas.BlobPath(id,
+ /*is_executable=*/false);
if (not link_path) {
return false;
}
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
index bb21c5e0..9b24bc80 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
@@ -74,7 +74,7 @@ auto BazelNetworkReader::ReadGitTree(ArtifactDigest const& digest)
Logger::Log(LogLevel::Debug, "Tree {} not found in CAS", digest.hash());
return std::nullopt;
}
- auto check_symlinks = [this](std::vector<bazel_re::Digest> const& ids) {
+ auto check_symlinks = [this](std::vector<ArtifactDigest> const& ids) {
size_t const size = ids.size();
size_t count = 0;
for (auto blobs : ReadIncrementally(ids)) {
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS
index 6eb9cc70..ef5abada 100644
--- a/src/buildtool/file_system/TARGETS
+++ b/src/buildtool/file_system/TARGETS
@@ -120,7 +120,7 @@
, "deps":
[ "git_cas"
, "git_types"
- , ["src/buildtool/common", "bazel_types"]
+ , ["src/buildtool/common", "common"]
, ["src/utils/cpp", "expected"]
, ["src/buildtool/storage", "config"]
, ["@", "gsl", "", "gsl"]
@@ -134,7 +134,6 @@
, ["src/utils/cpp", "hex_string"]
, ["src/utils/cpp", "gsl"]
, ["src/buildtool/file_system", "file_system_manager"]
- , ["src/buildtool/common", "common"]
]
, "cflags": ["-pthread"]
}
diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp
index c75029ee..b4c06224 100644
--- a/src/buildtool/file_system/git_repo.cpp
+++ b/src/buildtool/file_system/git_repo.cpp
@@ -22,7 +22,6 @@
#include <thread>
#include <unordered_set>
-#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/logging/log_level.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -1843,20 +1842,21 @@ auto GitRepo::ReadTree(std::string const& id,
// ignore_special==false.
if (not ignore_special) {
// we first gather all symlink candidates
- std::vector<bazel_re::Digest> symlinks{};
+ // to check symlinks in bulk, optimized for network-backed repos
+ std::vector<ArtifactDigest> symlinks{};
symlinks.reserve(entries.size()); // at most one symlink per entry
for (auto const& entry : entries) {
- for (auto const& item : entry.second) {
- if (IsSymlinkObject(item.type)) {
- symlinks.emplace_back(bazel_re::Digest(
- ArtifactDigest(ToHexString(entry.first),
- /*size=*/0,
- /*is_tree=*/false)));
- break; // no need to check other items with same hash
- }
+ if (std::any_of(entry.second.begin(),
+ entry.second.end(),
+ [](tree_entry_t const& item) {
+ return IsSymlinkObject(item.type);
+ })) {
+ symlinks.emplace_back(ToHexString(entry.first),
+ /*size=*/0,
+ /*is_tree=*/false);
}
}
- // we check symlinks in bulk, optimized for network-backed repos
+
if (not symlinks.empty() and
not std::invoke(check_symlinks.get(), symlinks)) {
Logger::Log(LogLevel::Error,
diff --git a/src/buildtool/file_system/git_repo.hpp b/src/buildtool/file_system/git_repo.hpp
index 4d1be53f..03ce92d8 100644
--- a/src/buildtool/file_system/git_repo.hpp
+++ b/src/buildtool/file_system/git_repo.hpp
@@ -24,7 +24,7 @@
#include <vector>
#include "gsl/gsl"
-#include "src/buildtool/common/bazel_types.hpp"
+#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/file_system/git_cas.hpp"
#include "src/buildtool/file_system/git_types.hpp"
#include "src/buildtool/storage/config.hpp"
@@ -71,7 +71,7 @@ class GitRepo {
// Checks whether a list of symlinks given by their hashes are
// non-upwards, based on content read from an actual backend.
using SymlinksCheckFunc =
- std::function<bool(std::vector<bazel_re::Digest> const&)>;
+ std::function<bool(std::vector<ArtifactDigest> const&)>;
GitRepo() = delete; // no default ctor
~GitRepo() noexcept = default;
diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp
index e0b25593..ad7a1c5b 100644
--- a/src/buildtool/file_system/git_tree.cpp
+++ b/src/buildtool/file_system/git_tree.cpp
@@ -63,11 +63,10 @@ class SymlinksChecker final {
: cas_{*cas} {}
[[nodiscard]] auto operator()(
- std::vector<bazel_re::Digest> const& ids) const noexcept -> bool {
+ std::vector<ArtifactDigest> const& ids) const noexcept -> bool {
return std::all_of(
- ids.begin(), ids.end(), [&cas = cas_](bazel_re::Digest const& id) {
- auto content = cas.ReadObject(ArtifactDigest(id).hash(),
- /*is_hex_id=*/true);
+ ids.begin(), ids.end(), [&cas = cas_](ArtifactDigest const& id) {
+ auto content = cas.ReadObject(id.hash(), /*is_hex_id=*/true);
return content.has_value() and PathIsNonUpwards(*content);
});
};
diff --git a/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp b/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp
index 198629bb..86861f2f 100644
--- a/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp
+++ b/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp
@@ -129,9 +129,7 @@ void ResolveKnownEntry(GitObjectToResolve const& obj,
}
auto children = source_git_repo->ReadTree(
entry_info.id,
- [](std::vector<bazel_re::Digest> const& /*unused*/) {
- return true;
- },
+ [](auto const& /*unused*/) { return true; },
/*is_hex_id=*/true);
if (not children) {
(*logger)(fmt::format("ResolveSymlinks: failed to read entries of "
diff --git a/src/buildtool/storage/local_cas.tpp b/src/buildtool/storage/local_cas.tpp
index 96224c3c..3f6af365 100644
--- a/src/buildtool/storage/local_cas.tpp
+++ b/src/buildtool/storage/local_cas.tpp
@@ -133,7 +133,7 @@ auto LocalCAS<kDoGlobalUplink>::LocalUplinkGitTree(
auto content = FileSystemManager::ReadFile(*tree_path);
auto id = NativeSupport::Unprefix(digest.hash());
auto check_symlinks =
- [this](std::vector<bazel_re::Digest> const& ids) -> bool {
+ [this](std::vector<ArtifactDigest> const& ids) -> bool {
for (auto const& id : ids) {
auto link_path = cas_file_.BlobPath(id);
std::optional<LargeObject> spliced;