From d51e7da74e902cbd5931b3429632be6feca29327 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 28 Nov 2023 12:37:38 +0100 Subject: Add files to CAS without fully keeping them in memory --- src/buildtool/file_system/object_cas.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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 { - auto const bytes = FileSystemManager::ReadFile(file_path); - if (bytes.has_value()) { - return ArtifactDigest::Create(*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; } -- cgit v1.2.3