diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-10-22 10:45:24 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-10-25 13:00:43 +0200 |
commit | 36ea313c98683f0b78b9817a96a54ace6bf4c519 (patch) | |
tree | e67f41f112a636994585fa1f4b57dd69e9d234ea /src | |
parent | f84e3442afed4f9e0eed31626a90a6fb31516b86 (diff) | |
download | justbuild-36ea313c98683f0b78b9817a96a54ace6bf4c519.tar.gz |
ObjectInfo: Fix digest creation in FromString
The digest tree check should take into account the protocol.
Also add a TODO to point out the currently needed code duplication.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/common/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/common/artifact.hpp | 9 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/buildtool/common/TARGETS b/src/buildtool/common/TARGETS index 73a6a5b6..17f4062d 100644 --- a/src/buildtool/common/TARGETS +++ b/src/buildtool/common/TARGETS @@ -87,6 +87,7 @@ ] , "deps": [ "bazel_types" + , "protocol_traits" , ["@", "json", "", "json"] , ["src/buildtool/crypto", "hash_function"] , ["src/buildtool/crypto", "hash_info"] diff --git a/src/buildtool/common/artifact.hpp b/src/buildtool/common/artifact.hpp index 6fcde282..403071a2 100644 --- a/src/buildtool/common/artifact.hpp +++ b/src/buildtool/common/artifact.hpp @@ -25,6 +25,7 @@ #include "nlohmann/json.hpp" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/identifier.hpp" +#include "src/buildtool/common/protocol_traits.hpp" #include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/crypto/hash_info.hpp" #include "src/buildtool/file_system/object_type.hpp" @@ -99,8 +100,14 @@ class Artifact { } auto const object_type = FromChar(*type.c_str()); + // TODO(design): The logic of ArtifactDigestFactory::Create is + // duplicated here to avoid a cyclic dependency. A better solution + // is advisable. auto hash_info = - HashInfo::Create(hash_type, id, IsTreeObject(object_type)); + HashInfo::Create(hash_type, + id, + ProtocolTraits::IsTreeAllowed(hash_type) and + IsTreeObject(object_type)); if (not hash_info) { Logger::Log( LogLevel::Debug, "{}", std::move(hash_info).error()); |