From 09a400e7a6ae4882ef770bf7eba3887050601ee8 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 11 Sep 2024 12:19:15 +0200 Subject: Store HashInfo in just-mr's ArchiveContent as content hash ...and use it to create ArtifactDigests. --- src/other_tools/ops_maps/archive_fetch_map.cpp | 31 +++++++++++++------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/other_tools/ops_maps/archive_fetch_map.cpp') diff --git a/src/other_tools/ops_maps/archive_fetch_map.cpp b/src/other_tools/ops_maps/archive_fetch_map.cpp index 17b33092..91d71ce6 100644 --- a/src/other_tools/ops_maps/archive_fetch_map.cpp +++ b/src/other_tools/ops_maps/archive_fetch_map.cpp @@ -27,21 +27,20 @@ void ProcessContent(std::filesystem::path const& content_path, std::filesystem::path const& target_name, gsl::not_null const& local_api, IExecutionApi const* remote_api, - std::string const& content, + ArtifactDigest const& content_digest, gsl::not_null const& stats, ArchiveFetchMap::SetterPtr const& setter, ArchiveFetchMap::LoggerPtr const& logger) { // try to back up to remote CAS if (remote_api != nullptr) { if (not local_api->RetrieveToCas( - {Artifact::ObjectInfo{ - .digest = ArtifactDigest{content, 0, /*is_tree=*/false}, - .type = ObjectType::File}}, + {Artifact::ObjectInfo{.digest = content_digest, + .type = ObjectType::File}}, *remote_api)) { // give a warning (*logger)(fmt::format("Failed to back up content {} from local CAS " "to remote", - content), + content_digest.hash()), /*fatal=*/false); } } @@ -53,7 +52,7 @@ void ProcessContent(std::filesystem::path const& content_path, } if (not FileSystemManager::CopyFile(content_path, target_name)) { (*logger)(fmt::format("Failed to copy content {} from CAS to {}", - content, + content_digest.hash(), target_name.string()), /*fatal=*/true); return; @@ -96,30 +95,30 @@ auto CreateArchiveFetchMap(gsl::not_null const& content_cas_map, storage, local_api, remote_api, - content = key.content, + hash_info = key.content_hash, stats, setter, logger]([[maybe_unused]] auto const& values) { // content is in local CAS now auto const& cas = storage->CAS(); - auto content_path = - cas.BlobPath(ArtifactDigest{content, 0, /*is_tree=*/false}, - /*is_executable=*/false) - .value(); + ArtifactDigest const digest{hash_info, 0}; + auto content_path = cas.BlobPath(digest, + /*is_executable=*/false) + .value(); ProcessContent(content_path, target_name, local_api, remote_api, - content, + digest, stats, setter, logger); }, - [logger, content = key.content](auto const& msg, bool fatal) { + [logger, hash = key.content_hash.Hash()](auto const& msg, + bool fatal) { (*logger)( - fmt::format("While ensuring content {} is in CAS:\n{}", - content, - msg), + fmt::format( + "While ensuring content {} is in CAS:\n{}", hash, msg), fatal); }); }; -- cgit v1.2.3