From dd12fcb5eea5970ac8ef6acd7a200c1e92ce81ea Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 29 Aug 2024 09:18:09 +0200 Subject: Replace bazel_re::Digest in GitRepo::SymlinksCheckFunc callback ...with ArtifactDigest. --- src/buildtool/file_system/git_repo.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/buildtool/file_system/git_repo.cpp') 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 #include -#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 symlinks{}; + // to check symlinks in bulk, optimized for network-backed repos + std::vector 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, -- cgit v1.2.3