From 4018960c59d3fd0702c714e404ac913b2e83c3f5 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 24 Oct 2024 11:18:49 +0200 Subject: serve service: Respond also with digest in serve repository tree RPCs ...besides the simple Git hash, if syncing was done. This way one can know what digest to ask for from the remote. The serve client also needs to now know what hash function the remote expects. The serve service proto file is updated accordingly. --- src/other_tools/root_maps/content_git_map.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/other_tools/root_maps/content_git_map.cpp') diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index ecae60ac..2338c066 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -71,7 +71,7 @@ void EnsureRootAsAbsent( // try to see if serve endpoint has the information to prepare the // root itself; this is redundant if root is not already cached if (is_cache_hit) { - auto serve_result = serve->RetrieveTreeFromArchive( + auto const serve_result = serve->RetrieveTreeFromArchive( key.archive.content_hash.Hash(), key.repo_type, key.subdir, @@ -80,12 +80,11 @@ void EnsureRootAsAbsent( if (serve_result) { // if serve has set up the tree, it must match what we // expect - auto const& served_tree_id = *serve_result; - if (tree_id != served_tree_id) { + if (tree_id != serve_result->tree) { (*logger)(fmt::format("Mismatch in served root tree " "id:\nexpected {}, but got {}", tree_id, - served_tree_id), + serve_result->tree), /*fatal=*/true); return; } @@ -1047,7 +1046,7 @@ auto CreateContentGitMap( // request the resolved subdir tree from the serve endpoint, if // given if (serve != nullptr) { - auto serve_result = serve->RetrieveTreeFromArchive( + auto const serve_result = serve->RetrieveTreeFromArchive( key.archive.content_hash.Hash(), key.repo_type, key.subdir, @@ -1058,7 +1057,7 @@ auto CreateContentGitMap( progress->TaskTracker().Stop(key.archive.origin); (*setter)(std::pair( nlohmann::json::array( - {FileRoot::kGitTreeMarker, *serve_result}), + {FileRoot::kGitTreeMarker, serve_result->tree}), /*is_cache_hit = */ false)); return; } -- cgit v1.2.3