diff options
author | Sascha Roloff <sascha.roloff@huawei.com> | 2022-09-02 14:28:50 +0200 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2022-09-12 14:45:34 +0200 |
commit | b877561106e0913de7200836d3c5d167d06e3243 (patch) | |
tree | 39003d30fa4e43c75fd7c7e0e34c9ca8500d9519 /src | |
parent | 39f3122dd0977a5ea4e58a81ba4665353dda3499 (diff) | |
download | justbuild-b877561106e0913de7200836d3c5d167d06e3243.tar.gz |
Fixed tree handling in compatible mode and added regression test
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/common/artifact_digest.hpp | 9 | ||||
-rw-r--r-- | src/buildtool/execution_api/local/local_api.hpp | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/buildtool/common/artifact_digest.hpp b/src/buildtool/common/artifact_digest.hpp index fdb4648e..d3f828af 100644 --- a/src/buildtool/common/artifact_digest.hpp +++ b/src/buildtool/common/artifact_digest.hpp @@ -22,10 +22,17 @@ class ArtifactDigest { explicit ArtifactDigest(bazel_re::Digest const& digest) noexcept : size_{gsl::narrow<std::size_t>(digest.size_bytes())}, hash_{NativeSupport::Unprefix(digest.hash())}, + // In compatible mode, no tree information is stored in a digest, + // NativeSupport::IsTree will always return false in compatible mode. is_tree_{NativeSupport::IsTree(digest.hash())} {} ArtifactDigest(std::string hash, std::size_t size, bool is_tree) noexcept - : size_{size}, hash_{std::move(hash)}, is_tree_{is_tree} { + : size_{size}, + hash_{std::move(hash)}, + // In compatible mode, no tree information is stored in a digest. This + // information is only relevant in native mode, since the hash needs + // to be prefixed accordingly. + is_tree_{not Compatibility::IsCompatible() and is_tree} { gsl_ExpectsAudit(not NativeSupport::IsPrefixed(hash_)); } diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index 1a43fe4b..06388287 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -161,7 +161,10 @@ class LocalApi final : public IExecutionApi { const noexcept -> std::vector<ArtifactDigest> final { std::vector<ArtifactDigest> result; for (auto const& digest : digests) { - if (not storage_->BlobPath(digest, false).has_value()) { + auto const& path = digest.is_tree() + ? storage_->TreePath(digest) + : storage_->BlobPath(digest, false); + if (not path) { result.push_back(digest); } } |