From 6e2284eeea2baf3b0c7683749afdea2b37785f46 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 10 Sep 2024 12:25:11 +0200 Subject: Use ArtifactDigestFactory in TargetCacheEntry ...to create ArtifactDigests. --- src/buildtool/storage/target_cache_entry.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/buildtool/storage/target_cache_entry.cpp b/src/buildtool/storage/target_cache_entry.cpp index f6659256..263993c8 100644 --- a/src/buildtool/storage/target_cache_entry.cpp +++ b/src/buildtool/storage/target_cache_entry.cpp @@ -20,8 +20,11 @@ #include #include +#include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/common/artifact_digest_factory.hpp" #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" +#include "src/utils/cpp/expected.hpp" #include "src/utils/cpp/gsl.hpp" auto TargetCacheEntry::FromTarget( @@ -80,9 +83,16 @@ auto TargetCacheEntry::ToImpliedIds(std::string const& entry_key_hash) try { for (auto const& x : desc_["implied export targets"]) { if (x != entry_key_hash) { - result.emplace_back(Artifact::ObjectInfo{ - .digest = ArtifactDigest{x, 0, /*is_tree=*/false}, - .type = ObjectType::File}); + auto digest = ArtifactDigestFactory::Create( + hash_type_, x, 0, /*is_tree=*/false); + if (not digest) { + Logger::Log( + LogLevel::Debug, "{}", std::move(digest).error()); + return std::nullopt; + } + result.emplace_back( + Artifact::ObjectInfo{.digest = *std::move(digest), + .type = ObjectType::File}); } } } catch (std::exception const& ex) { -- cgit v1.2.3