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/distdir_git_map.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/other_tools/root_maps/distdir_git_map.cpp') diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp index 82c0c623..ef460949 100644 --- a/src/other_tools/root_maps/distdir_git_map.cpp +++ b/src/other_tools/root_maps/distdir_git_map.cpp @@ -224,21 +224,20 @@ auto CreateDistdirGitMap( if (not *has_tree) { // try to see if serve endpoint has the // information to prepare the root itself - auto serve_result = + auto const serve_result = serve->RetrieveTreeFromDistdir( key.content_list, /*sync_tree=*/false); if (serve_result) { // if serve has set up the tree, it must // match what we expect - auto const& served_tree_id = *serve_result; - if (distdir_tree_id != served_tree_id) { + if (distdir_tree_id != serve_result->tree) { (*logger)( fmt::format( "Mismatch in served root tree " "id:\nexpected {}, but got {}", distdir_tree_id, - served_tree_id), + serve_result->tree), /*fatal=*/true); return; } @@ -376,19 +375,18 @@ auto CreateDistdirGitMap( } // try to see if serve endpoint has the information to // prepare the root itself - auto serve_result = + auto const serve_result = serve->RetrieveTreeFromDistdir(key.content_list, /*sync_tree=*/false); 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; } @@ -520,18 +518,17 @@ auto CreateDistdirGitMap( // now ask serve endpoint if it can set up the root; as this is for // a present root, a corresponding remote endpoint is needed if (serve != nullptr and remote_api != nullptr) { - auto serve_result = + auto const serve_result = serve->RetrieveTreeFromDistdir(key.content_list, /*sync_tree=*/true); 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; } -- cgit v1.2.3