summaryrefslogtreecommitdiff
path: root/src/other_tools/root_maps
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2025-01-21 16:14:47 +0100
committerMaksim Denisov <denisov.maksim@huawei.com>2025-01-23 16:50:37 +0100
commit771a4fa61dde2999147d2b244ed21e23c2c45aac (patch)
tree1f175b27e9506ad329a1e85f48d91fba4c8098e8 /src/other_tools/root_maps
parenta8ec684b2ef5c849b2ab8056c0b54be28ef4d5e3 (diff)
downloadjustbuild-771a4fa61dde2999147d2b244ed21e23c2c45aac.tar.gz
JustMr: ContentGitMap: Use serve calls
...instead of EnsureAbsentRootOnServe.
Diffstat (limited to 'src/other_tools/root_maps')
-rw-r--r--src/other_tools/root_maps/TARGETS3
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp39
2 files changed, 22 insertions, 20 deletions
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS
index dbd9c359..9e0c9912 100644
--- a/src/other_tools/root_maps/TARGETS
+++ b/src/other_tools/root_maps/TARGETS
@@ -138,7 +138,9 @@
, "private-deps":
[ "root_utils"
, ["@", "fmt", "", "fmt"]
+ , ["src/buildtool/common", "artifact_digest_factory"]
, ["src/buildtool/common", "common"]
+ , ["src/buildtool/crypto", "hash_function"]
, ["src/buildtool/crypto", "hash_info"]
, ["src/buildtool/file_system", "file_root"]
, ["src/buildtool/file_system", "file_system_manager"]
@@ -150,6 +152,7 @@
, ["src/other_tools/git_operations", "git_ops_types"]
, ["src/other_tools/git_operations", "git_repo_remote"]
, ["src/utils/archive", "archive_ops"]
+ , ["src/utils/cpp", "expected"]
, ["src/utils/cpp", "tmp_dir"]
]
}
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index cbe95096..717ce065 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -23,6 +23,8 @@
#include "fmt/core.h"
#include "src/buildtool/common/artifact_digest.hpp"
+#include "src/buildtool/common/artifact_digest_factory.hpp"
+#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/crypto/hash_info.hpp"
#include "src/buildtool/file_system/file_root.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
@@ -35,6 +37,7 @@
#include "src/other_tools/git_operations/git_repo_remote.hpp"
#include "src/other_tools/root_maps/root_utils.hpp"
#include "src/utils/archive/archive_ops.hpp"
+#include "src/utils/cpp/expected.hpp"
#include "src/utils/cpp/tmp_dir.hpp"
namespace {
@@ -65,9 +68,9 @@ void EnsureRootAsAbsent(
ArchiveRepoInfo const& key,
ServeApi const* serve,
gsl::not_null<StorageConfig const*> const& native_storage_config,
- StorageConfig const* compat_storage_config,
- IExecutionApi const* local_api,
- IExecutionApi const* remote_api,
+ StorageConfig const* /*compat_storage_config*/,
+ IExecutionApi const* /*local_api*/,
+ IExecutionApi const* /*remote_api*/,
bool is_cache_hit,
ContentGitMap::SetterPtr const& ws_setter,
ContentGitMap::LoggerPtr const& logger) {
@@ -116,28 +119,24 @@ void EnsureRootAsAbsent(
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) {
- (*logger)(
- fmt::format("Missing or incompatible remote-execution "
- "endpoint needed to sync workspace root {} "
- "with the serve endpoint.",
- tree_id),
- /*fatal=*/true);
+ auto digest =
+ ArtifactDigestFactory::Create(HashFunction::Type::GitSHA1,
+ tree_id,
+ /*size_unknown=*/0,
+ /*is_tree=*/true);
+ if (not digest.has_value()) {
+ (*logger)(std::move(digest).error(), /*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_root*/
- native_storage_config,
- compat_storage_config,
- local_api,
- remote_api,
- logger,
- /*no_sync_is_fatal=*/true)) {
+ auto uploaded = serve->UploadTree(
+ *digest, native_storage_config->GitRoot());
+ if (not uploaded.has_value()) {
+ (*logger)(std::move(uploaded).error().Message(),
+ /*fatal=*/true);
return;
}
}