diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/file_system/object_cas.hpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/buildtool/file_system/object_cas.hpp b/src/buildtool/file_system/object_cas.hpp index 93b2055b..6dd1ae9f 100644 --- a/src/buildtool/file_system/object_cas.hpp +++ b/src/buildtool/file_system/object_cas.hpp @@ -97,6 +97,21 @@ class ObjectCAS { return blob_path; } + /// \brief Calculate the digest for a file. + /// \param file_path File for which the digest needs to be calculated. + /// \return File digest. + [[nodiscard]] static auto CreateDigest( + std::filesystem::path const& file_path) noexcept + -> std::optional<bazel_re::Digest> { + 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; + } + private: // For `Tree` the underlying storage type is non-executable file. static constexpr auto kStorageType = @@ -113,18 +128,6 @@ class ObjectCAS { return ArtifactDigest::Create<kType>(bytes); } - [[nodiscard]] static auto CreateDigest( - std::filesystem::path const& file_path) noexcept - -> std::optional<bazel_re::Digest> { - 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; - } - [[nodiscard]] auto IsAvailable( bazel_re::Digest const& digest, std::filesystem::path const& path) const noexcept -> bool { |