diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-11 18:15:09 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-13 14:41:00 +0200 |
commit | dba28855e291dcb587cf1493446cae79f2528223 (patch) | |
tree | 404216492c005a8d5ffdff0dcb048e5d59128b77 /src/buildtool/execution_api/execution_service/execution_server.cpp | |
parent | 27a696c4d6d5815b4355d93c767e499028bb7e2f (diff) | |
download | justbuild-dba28855e291dcb587cf1493446cae79f2528223.tar.gz |
Check compatibility in execution services based on the hash type
Diffstat (limited to 'src/buildtool/execution_api/execution_service/execution_server.cpp')
-rw-r--r-- | src/buildtool/execution_api/execution_service/execution_server.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp index 6e3c77ab..2a1e8bca 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.cpp +++ b/src/buildtool/execution_api/execution_service/execution_server.cpp @@ -276,7 +276,12 @@ namespace { ::bazel_re::OutputDirectory out_dir{}; *(out_dir.mutable_path()) = std::move(path); - if (ProtocolTraits::Instance().IsCompatible()) { + if (ProtocolTraits::IsNative(storage.GetHashFunction().GetType())) { + // In native mode: Set the directory digest directly. + (*out_dir.mutable_tree_digest()) = + ArtifactDigestFactory::ToBazel(digest); + } + else { // In compatible mode: Create a tree digest from directory // digest on the fly and set tree digest. LocalCasReader reader(&storage.CAS()); @@ -299,11 +304,6 @@ namespace { (*out_dir.mutable_tree_digest()) = ArtifactDigestFactory::ToBazel(*cas_digest); } - else { - // In native mode: Set the directory digest directly. - (*out_dir.mutable_tree_digest()) = - ArtifactDigestFactory::ToBazel(digest); - } return std::move(out_dir); } @@ -404,16 +404,17 @@ namespace { action_digest.hash())}; } - auto const input_root_digest = ArtifactDigestFactory::FromBazel( - storage.GetHashFunction().GetType(), action.input_root_digest()); + auto const hash_type = storage.GetHashFunction().GetType(); + auto const input_root_digest = + ArtifactDigestFactory::FromBazel(hash_type, action.input_root_digest()); if (not input_root_digest) { return unexpected{input_root_digest.error()}; } auto const input_root_path = - ProtocolTraits::Instance().IsCompatible() - ? storage.CAS().BlobPath(*input_root_digest, - /*is_executable=*/false) - : storage.CAS().TreePath(*input_root_digest); + ProtocolTraits::IsNative(hash_type) + ? storage.CAS().TreePath(*input_root_digest) + : storage.CAS().BlobPath(*input_root_digest, + /*is_executable=*/false); if (not input_root_path) { return unexpected{ |