summaryrefslogtreecommitdiff
path: root/src/other_tools/ops_maps
diff options
context:
space:
mode:
Diffstat (limited to 'src/other_tools/ops_maps')
-rw-r--r--src/other_tools/ops_maps/TARGETS1
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp31
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp2
3 files changed, 17 insertions, 17 deletions
diff --git a/src/other_tools/ops_maps/TARGETS b/src/other_tools/ops_maps/TARGETS
index 1baf11e5..f30cdf22 100644
--- a/src/other_tools/ops_maps/TARGETS
+++ b/src/other_tools/ops_maps/TARGETS
@@ -61,6 +61,7 @@
, ["src/buildtool/file_system/symlinks_map", "pragma_special"]
, ["src/buildtool/execution_api/common", "common"]
, ["src/buildtool/multithreading", "async_map_consumer"]
+ , ["src/other_tools/just_mr", "mirrors"]
, ["src/utils/cpp", "hash_combine"]
, ["@", "json", "", "json"]
]
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index b6b8712e..2deb8060 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -20,18 +20,23 @@
#include "src/other_tools/just_mr/progress_reporting/progress.hpp"
#include "src/other_tools/just_mr/progress_reporting/statistics.hpp"
#include "src/other_tools/utils/content.hpp"
+#include "src/other_tools/utils/curl_url_handle.hpp"
auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths,
+ MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
IExecutionApi* local_api,
IExecutionApi* remote_api,
std::size_t jobs) -> ContentCASMap {
- auto ensure_in_cas = [just_mr_paths, ca_info, local_api, remote_api](
- auto /*unused*/,
- auto setter,
- auto logger,
- auto /*unused*/,
- auto const& key) {
+ auto ensure_in_cas = [just_mr_paths,
+ additional_mirrors,
+ ca_info,
+ local_api,
+ remote_api](auto /*unused*/,
+ auto setter,
+ auto logger,
+ auto /*unused*/,
+ auto const& key) {
// check if content already in CAS
auto const& cas = Storage::Instance().CAS();
auto digest = ArtifactDigest(key.content, 0, false);
@@ -69,17 +74,9 @@ auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths,
/*fatal=*/true);
return;
}
- // now do the actual fetch; first, try the main fetch URL
- auto data = NetworkFetch(key.fetch_url, ca_info);
- if (not data) {
- // try the mirrors, in order, if given
- for (auto const& mirror : key.mirrors) {
- data = NetworkFetch(mirror, ca_info);
- if (data) {
- break;
- }
- }
- }
+ // now do the actual fetch
+ auto data = NetworkFetchWithMirrors(
+ key.fetch_url, key.mirrors, ca_info, additional_mirrors);
if (not data) {
(*logger)(fmt::format("Failed to fetch a file with id {} from "
"provided remotes",
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index 16b790d0..810727cd 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -24,6 +24,7 @@
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/file_system/symlinks_map/pragma_special.hpp"
#include "src/buildtool/multithreading/async_map_consumer.hpp"
+#include "src/other_tools/just_mr/mirrors.hpp"
#include "src/utils/cpp/hash_combine.hpp"
struct ArchiveContent {
@@ -65,6 +66,7 @@ struct ArchiveRepoInfo {
using ContentCASMap = AsyncMapConsumer<ArchiveContent, bool>;
[[nodiscard]] auto CreateContentCASMap(LocalPathsPtr const& just_mr_paths,
+ MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
IExecutionApi* local_api,
IExecutionApi* remote_api,