diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-21 16:08:21 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-23 16:50:37 +0100 |
commit | a8ec684b2ef5c849b2ab8056c0b54be28ef4d5e3 (patch) | |
tree | c588aea4112fd2bba2d124770646928faa98f592 /src | |
parent | d2eed1607c87a878e5336c891d44dbc40ef71476 (diff) | |
download | justbuild-a8ec684b2ef5c849b2ab8056c0b54be28ef4d5e3.tar.gz |
JustMr: ContentGitMap: Remove code duplication.
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/root_maps/content_git_map.cpp | 49 |
1 files changed, 12 insertions, 37 deletions
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index 8a903943..cbe95096 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -81,6 +81,7 @@ void EnsureRootAsAbsent( if (not *has_tree) { // try to see if serve endpoint has the information to prepare the // root itself; this is redundant if root is not already cached + bool on_serve = false; if (is_cache_hit) { auto const serve_result = serve->RetrieveTreeFromArchive( key.archive.content_hash.Hash(), @@ -99,46 +100,20 @@ void EnsureRootAsAbsent( /*fatal=*/true); return; } + on_serve = true; } - else { - // check if serve failure was due to archive content not - // being found or it is otherwise fatal - if (serve_result.error() == GitLookupError::Fatal) { - (*logger)( - fmt::format("Serve endpoint failed to set up " - "root from known archive content {}", - key.archive.content_hash.Hash()), - /*fatal=*/true); - return; - } - if (remote_api == nullptr) { - (*logger)( - fmt::format( - "Missing or incompatible remote-execution " - "endpoint needed to sync workspace root {} " - "with the serve endpoint.", - tree_id), - /*fatal=*/true); - return; - } - // the tree is known locally, so we can upload it to remote - // CAS for the serve endpoint to retrieve it and set up the - // root - if (not EnsureAbsentRootOnServe( - *serve, - tree_id, - native_storage_config->GitRoot(), /*repo_path*/ - native_storage_config, - compat_storage_config, - local_api, - remote_api, - logger, - /*no_sync_is_fatal=*/true)) { - return; - } + + if (not serve_result.has_value() and + serve_result.error() == GitLookupError::Fatal) { + (*logger)(fmt::format("Serve endpoint failed to set up " + "root from known archive content {}", + key.archive.content_hash.Hash()), + /*fatal=*/true); + return; } } - else { + + if (not on_serve) { // the tree is known locally, so we can upload it to remote CAS // for the serve endpoint to retrieve it and set up the root if (remote_api == nullptr) { |