summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-11-28 12:37:38 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-11-30 14:50:41 +0100
commitd51e7da74e902cbd5931b3429632be6feca29327 (patch)
tree88003a8c34b1b413c19d53e18814a7f4ddf16666
parentcd66c1f47fbfc53d60d37d883c9c709c93e54a36 (diff)
downloadjustbuild-d51e7da74e902cbd5931b3429632be6feca29327.tar.gz
Add files to CAS without fully keeping them in memory
-rw-r--r--src/buildtool/file_system/object_cas.hpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/buildtool/file_system/object_cas.hpp b/src/buildtool/file_system/object_cas.hpp
index 2af59bb9..e7cd7f1b 100644
--- a/src/buildtool/file_system/object_cas.hpp
+++ b/src/buildtool/file_system/object_cas.hpp
@@ -113,9 +113,11 @@ class ObjectCAS {
[[nodiscard]] static auto CreateDigest(
std::filesystem::path const& file_path) noexcept
-> std::optional<bazel_re::Digest> {
- auto const bytes = FileSystemManager::ReadFile(file_path);
- if (bytes.has_value()) {
- return ArtifactDigest::Create<kType>(*bytes);
+ bool is_tree = kType == ObjectType::Tree;
+ auto hash = HashFunction::ComputeHashFile(file_path, is_tree);
+ if (hash) {
+ return ArtifactDigest(
+ hash->first.HexString(), hash->second, is_tree);
}
return std::nullopt;
}