From 15e6dcc0996234429f59c2c1d9dd314c3715a265 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 10 Oct 2023 15:18:28 +0200 Subject: just-mr fetch: Fix exception on fetched data hash mismatch After successfully fetching data over the network for an archive, if the optional checksums are not provided, the code will throw if there is a mismatch between the hash of the fetched data stream and the provided content hash. This commit fixes the issue by adding an additional check which properly handles the possible mismatch. (cherry-picked from 9acaa7f60c88c97f58b757ffb6ce206f3f2953a2) --- src/other_tools/ops_maps/content_cas_map.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp index 4a25b15c..2d1b0de7 100644 --- a/src/other_tools/ops_maps/content_cas_map.cpp +++ b/src/other_tools/ops_maps/content_cas_map.cpp @@ -120,14 +120,22 @@ auto CreateContentCASMap(JustMR::PathsPtr const& just_mr_paths, } // add the fetched data to CAS auto path = JustMR::Utils::AddToCAS(*data); - // check one last time if content is in CAS now + // check that storing the fetched data succeeded if (not path) { - (*logger)(fmt::format("Failed to fetch a file with id {} from {}", - key.content, + (*logger)(fmt::format("Failed to store fetched content from {}", key.fetch_url), /*fatal=*/true); return; } + // check that the data we stored actually produces the requested digest + if (not cas.BlobPath(digest, /*is_executable=*/false)) { + (*logger)(fmt::format( + "Content {} was not found at given fetch location {}", + key.content, + key.fetch_url), + /*fatal=*/true); + return; + } JustMRProgress::Instance().TaskTracker().Stop(key.origin); (*setter)(true); }; -- cgit v1.2.3