summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/serve_api/serve_service/serve_server_implementation.cpp14
-rw-r--r--src/buildtool/serve_api/serve_service/source_tree.cpp25
2 files changed, 19 insertions, 20 deletions
diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
index bfa5bde0..89b2f68d 100644
--- a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
+++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
@@ -187,14 +187,12 @@ auto ServeServerImpl::Run(
}
auto const& info_str = nlohmann::to_string(info);
- Logger::Log(
- LogLevel::Info,
- fmt::format(
- "{}serve{} service{} started: {}",
- ProtocolTraits::Instance().IsCompatible() ? "compatible " : "",
- with_execute ? " and execute" : "",
- with_execute ? "s" : "",
- info_str));
+ Logger::Log(LogLevel::Info,
+ "{}serve{} service{} started: {}",
+ ProtocolTraits::IsNative(hash_type) ? "" : "compatible ",
+ with_execute ? " and execute" : "",
+ with_execute ? "s" : "",
+ info_str);
if (not info_file_.empty()) {
if (not TryWrite(info_file_, info_str)) {
diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp
index ed6fcae0..567d61bb 100644
--- a/src/buildtool/serve_api/serve_service/source_tree.cpp
+++ b/src/buildtool/serve_api/serve_service/source_tree.cpp
@@ -287,7 +287,8 @@ auto SourceTreeService::SyncGitEntryToCas(
std::string const& object_hash,
std::filesystem::path const& repo_path) const noexcept
-> std::remove_cvref_t<decltype(TResponse::OK)> {
- if (IsTreeObject(kType) and ProtocolTraits::Instance().IsCompatible()) {
+ auto const hash_type = storage_config_.hash_function.GetType();
+ if (IsTreeObject(kType) and not ProtocolTraits::IsTreeAllowed(hash_type)) {
logger_->Emit(LogLevel::Error,
"Cannot sync tree {} from repository {} with "
"the remote in compatible mode",
@@ -302,11 +303,8 @@ auto SourceTreeService::SyncGitEntryToCas(
LogLevel::Error, "Failed to SetGitCAS at {}", repo_path.string());
return TResponse::INTERNAL_ERROR;
}
- auto const digest =
- ArtifactDigestFactory::Create(storage_config_.hash_function.GetType(),
- object_hash,
- 0,
- IsTreeObject(kType));
+ auto const digest = ArtifactDigestFactory::Create(
+ hash_type, object_hash, 0, IsTreeObject(kType));
if (not digest) {
logger_->Emit(LogLevel::Error, "{}", digest.error());
return TResponse::INTERNAL_ERROR;
@@ -967,6 +965,8 @@ auto SourceTreeService::ServeDistdirTree(
content_list{};
content_list.reserve(request->distfiles().size());
+ bool const is_native =
+ ProtocolTraits::IsNative(storage_config_.hash_function.GetType());
for (auto const& kv : request->distfiles()) {
bool blob_found{};
std::string blob_digest; // The digest of the requested distfile, taken
@@ -984,7 +984,7 @@ auto SourceTreeService::ServeDistdirTree(
0,
/*is_tree=*/false);
- if (not ProtocolTraits::Instance().IsCompatible()) {
+ if (is_native) {
blob_found = digest and cas.BlobPath(*digest, kv.executable());
}
if (blob_found) {
@@ -1054,8 +1054,8 @@ auto SourceTreeService::ServeDistdirTree(
}
if (not blob_found) {
// check remote CAS
- if (not ProtocolTraits::Instance().IsCompatible() and
- digest and apis_.remote->IsAvailable(*digest)) {
+ if (is_native and digest and
+ apis_.remote->IsAvailable(*digest)) {
// retrieve content to local CAS
if (not apis_.remote->RetrieveToCas(
{Artifact::ObjectInfo{
@@ -1316,11 +1316,12 @@ auto SourceTreeService::ServeTree(
}
}
// check also in the local CAS
- auto const digest = ArtifactDigestFactory::Create(
- storage_config_.hash_function.GetType(), tree_id, 0, /*is_tree=*/true);
+ auto const hash_type = storage_config_.hash_function.GetType();
+ auto const digest =
+ ArtifactDigestFactory::Create(hash_type, tree_id, 0, /*is_tree=*/true);
if (digest and apis_.local->IsAvailable(*digest)) {
// upload tree to remote CAS; only possible in native mode
- if (ProtocolTraits::Instance().IsCompatible()) {
+ if (not ProtocolTraits::IsNative(hash_type)) {
logger_->Emit(LogLevel::Error,
"Cannot sync tree {} from local CAS with the remote "
"in compatible mode",