From 2a17d5bbfb1cde47af676f49f7409c7a0014758b Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Thu, 9 Nov 2023 11:56:09 +0100 Subject: just-mr archives fetch: Add logic for local mirrors and preferred hostnames --- src/other_tools/root_maps/TARGETS | 1 + src/other_tools/root_maps/content_git_map.cpp | 23 +++++++++-------------- src/other_tools/root_maps/content_git_map.hpp | 2 ++ 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src/other_tools/root_maps') diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS index fff48505..9340cd14 100644 --- a/src/other_tools/root_maps/TARGETS +++ b/src/other_tools/root_maps/TARGETS @@ -86,6 +86,7 @@ [ ["src/buildtool/serve_api/remote", "serve_api"] , ["src/buildtool/execution_api/common", "common"] , ["src/buildtool/common", "user_structs"] + , ["src/other_tools/just_mr", "mirrors"] , ["src/other_tools/ops_maps", "content_cas_map"] , ["src/other_tools/ops_maps", "import_to_git_map"] , ["src/buildtool/file_system/symlinks_map", "resolve_symlinks_map"] diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index a39b6cde..79500f5d 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -302,6 +302,7 @@ auto CreateContentGitMap( gsl::not_null const& content_cas_map, gsl::not_null const& import_to_git_map, LocalPathsPtr const& just_mr_paths, + MirrorsPtr const& additional_mirrors, CAInfoPtr const& ca_info, gsl::not_null const& resolve_symlinks_map, gsl::not_null const& critical_git_op_map, @@ -315,6 +316,7 @@ auto CreateContentGitMap( resolve_symlinks_map, critical_git_op_map, just_mr_paths, + additional_mirrors, ca_info, serve_api, local_api, @@ -505,6 +507,7 @@ auto CreateContentGitMap( sha256 = key.archive.sha256, sha512 = key.archive.sha512, pragma_special = key.pragma_special, + additional_mirrors, ca_info, origin = key.archive.origin, absent = key.absent, @@ -708,20 +711,12 @@ auto CreateContentGitMap( /*fatal=*/true); return; } - // now do the actual fetch; first, try the - // main fetch URL - auto data = - NetworkFetch(fetch_url, ca_info); - if (not data) { - // try the mirrors, in order, if given - for (auto const& mirror : mirrors) { - data = - NetworkFetch(mirror, ca_info); - if (data) { - break; - } - } - } + // now do the actual fetch + auto data = NetworkFetchWithMirrors( + fetch_url, + mirrors, + ca_info, + additional_mirrors); if (not data) { (*logger)( fmt::format("Failed to fetch a " diff --git a/src/other_tools/root_maps/content_git_map.hpp b/src/other_tools/root_maps/content_git_map.hpp index e0a564f5..986a0531 100644 --- a/src/other_tools/root_maps/content_git_map.hpp +++ b/src/other_tools/root_maps/content_git_map.hpp @@ -21,6 +21,7 @@ #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/file_system/symlinks_map/resolve_symlinks_map.hpp" #include "src/buildtool/serve_api/remote/serve_api.hpp" +#include "src/other_tools/just_mr/mirrors.hpp" #include "src/other_tools/ops_maps/content_cas_map.hpp" #include "src/other_tools/ops_maps/import_to_git_map.hpp" @@ -33,6 +34,7 @@ using ContentGitMap = gsl::not_null const& content_cas_map, gsl::not_null const& import_to_git_map, LocalPathsPtr const& just_mr_paths, + MirrorsPtr const& additional_mirrors, CAInfoPtr const& ca_info, gsl::not_null const& resolve_symlinks_map, gsl::not_null const& critical_git_op_map, -- cgit v1.2.3