summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-10-10 15:18:28 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-10-16 15:07:44 +0200
commit9acaa7f60c88c97f58b757ffb6ce206f3f2953a2 (patch)
treea6508c515ad4855ed9a851e1ca053df2a147dfbe
parentf0fe744acf283ee027e8483d00fdb65263aac698 (diff)
downloadjustbuild-9acaa7f60c88c97f58b757ffb6ce206f3f2953a2.tar.gz
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.
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp14
1 files 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 898aa4f1..01a7f484 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -133,14 +133,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);
};