summaryrefslogtreecommitdiff
path: root/src
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-17 10:27:11 +0200
commit15e6dcc0996234429f59c2c1d9dd314c3715a265 (patch)
tree42de06bcbad8dad5a01e4ef0827120b9fa9388a5 /src
parent302c994ba3342a3227178ab9e86704bfdff29ffc (diff)
downloadjustbuild-15e6dcc0996234429f59c2c1d9dd314c3715a265.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. (cherry-picked from 9acaa7f60c88c97f58b757ffb6ce206f3f2953a2)
Diffstat (limited to 'src')
-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 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);
};