summaryrefslogtreecommitdiff
path: root/src/other_tools/root_maps
diff options
context:
space:
mode:
Diffstat (limited to 'src/other_tools/root_maps')
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp31
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp11
-rw-r--r--src/other_tools/root_maps/distdir_git_map.cpp21
-rw-r--r--src/other_tools/root_maps/foreign_file_git_map.cpp10
4 files changed, 32 insertions, 41 deletions
diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index f221f63f..8f96eb82 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -82,13 +82,13 @@ void EnsureRootAsAbsent(
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->RetrieveTreeFromCommit(repo_info.hash,
repo_info.subdir,
/*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;
+ auto const& served_tree_id = serve_result->tree;
if (tree_id != served_tree_id) {
(*logger)(fmt::format("Mismatch in served root tree "
"id:\nexpected {}, but got {}",
@@ -671,7 +671,7 @@ void EnsureCommit(
if (serve != nullptr) {
// if root purely absent, request only the subdir tree
if (repo_info.absent and not fetch_absent) {
- auto serve_result =
+ auto const serve_result =
serve->RetrieveTreeFromCommit(repo_info.hash,
repo_info.subdir,
/*sync_tree = */ false);
@@ -683,7 +683,7 @@ void EnsureCommit(
{repo_info.ignore_special
? FileRoot::kGitTreeIgnoreSpecialMarker
: FileRoot::kGitTreeMarker,
- *std::move(serve_result)}),
+ serve_result->tree}),
/*is_cache_hit=*/false));
return;
}
@@ -700,12 +700,13 @@ void EnsureCommit(
// otherwise, request (and sync) the whole commit tree, to ensure
// we maintain the id file association
else {
- auto serve_result =
+ auto const serve_result =
serve->RetrieveTreeFromCommit(repo_info.hash,
/*subdir = */ ".",
/*sync_tree = */ true);
if (serve_result) {
- auto const& root_tree_id = *serve_result;
+ auto const root_tree_id = serve_result->tree;
+ auto const remote_digest = serve_result->digest;
// verify if we know the tree already in the local Git cache
GitOpKey op_key = {.params =
{
@@ -721,6 +722,7 @@ void EnsureCommit(
ts,
{std::move(op_key)},
[root_tree_id,
+ remote_digest,
tree_id_file,
repo_info,
repo_root,
@@ -875,18 +877,13 @@ void EnsureCommit(
}
}
- // try to get root tree from remote CAS
- auto const root_digest =
- ArtifactDigestFactory::Create(
- native_storage_config->hash_function
- .GetType(),
- root_tree_id,
- 0,
- /*is_tree=*/true);
- if (remote_api != nullptr and root_digest and
+ // try to get root tree from remote CAS; use the
+ // digest received from serve; whether native or
+ // compatible, it will either way be imported to Git
+ if (remote_api != nullptr and remote_digest and
remote_api->RetrieveToCas(
{Artifact::ObjectInfo{
- .digest = *root_digest,
+ .digest = *remote_digest,
.type = ObjectType::Tree}},
*local_api)) {
progress->TaskTracker().Stop(repo_info.origin);
@@ -907,7 +904,7 @@ void EnsureCommit(
}
if (not local_api->RetrieveToPaths(
{Artifact::ObjectInfo{
- .digest = *root_digest,
+ .digest = *remote_digest,
.type = ObjectType::Tree}},
{tmp_dir->GetPath()})) {
(*logger)(fmt::format(
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;
}
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;
}
diff --git a/src/other_tools/root_maps/foreign_file_git_map.cpp b/src/other_tools/root_maps/foreign_file_git_map.cpp
index 8bc09b86..25c77947 100644
--- a/src/other_tools/root_maps/foreign_file_git_map.cpp
+++ b/src/other_tools/root_maps/foreign_file_git_map.cpp
@@ -156,17 +156,15 @@ void HandleAbsentForeignFile(ForeignFileInfo const& key,
/*is_cache_hit=*/false));
return;
}
- auto serve_result = serve->RetrieveTreeFromForeignFile(
+ auto const serve_result = serve->RetrieveTreeFromForeignFile(
key.archive.content_hash.Hash(), key.name, key.executable);
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 serve has set up the tree, it must match what we expect
+ if (tree_id != serve_result->tree) {
(*logger)(fmt::format("Mismatch in served root tree "
"id: expected {}, but got {}",
tree_id,
- served_tree_id),
+ serve_result->tree),
/*fatal=*/true);
return;
}