diff options
Diffstat (limited to 'src/buildtool/file_system/object_cas.hpp')
-rw-r--r-- | src/buildtool/file_system/object_cas.hpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/buildtool/file_system/object_cas.hpp b/src/buildtool/file_system/object_cas.hpp index 95091773..d8ea71a2 100644 --- a/src/buildtool/file_system/object_cas.hpp +++ b/src/buildtool/file_system/object_cas.hpp @@ -23,7 +23,6 @@ #include "gsl/gsl" #include "src/buildtool/common/artifact_digest.hpp" -#include "src/buildtool/common/bazel_types.hpp" #include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/file_system/file_storage.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" @@ -43,7 +42,7 @@ class ObjectCAS { public: /// \brief Callback type for checking blob existence. /// \returns true if a blob for the given digest exists at the given path. - using ExistsFunc = std::function<bool(bazel_re::Digest const&, + using ExistsFunc = std::function<bool(ArtifactDigest const&, std::filesystem::path const&)>; /// \brief Create new object CAS in store_path directory. @@ -77,7 +76,7 @@ class ObjectCAS { /// \param bytes The bytes do create the blob from. /// \returns Digest of the stored blob or nullopt in case of error. [[nodiscard]] auto StoreBlobFromBytes(std::string const& bytes) - const noexcept -> std::optional<bazel_re::Digest> { + const noexcept -> std::optional<ArtifactDigest> { return StoreBlob(bytes, /*is_owner=*/true); } @@ -87,16 +86,16 @@ class ObjectCAS { /// \returns Digest of the stored blob or nullopt in case of error. [[nodiscard]] auto StoreBlobFromFile(std::filesystem::path const& file_path, bool is_owner = false) const noexcept - -> std::optional<bazel_re::Digest> { + -> std::optional<ArtifactDigest> { return StoreBlob(file_path, is_owner); } /// \brief Get path to blob. /// \param digest Digest of the blob to lookup. /// \returns Path to blob if found or nullopt otherwise. - [[nodiscard]] auto BlobPath(bazel_re::Digest const& digest) const noexcept + [[nodiscard]] auto BlobPath(ArtifactDigest const& digest) const noexcept -> std::optional<std::filesystem::path> { - auto id = NativeSupport::Unprefix(digest.hash()); + auto const& id = digest.hash(); auto blob_path = file_store_.GetPath(id); if (not IsAvailable(digest, blob_path)) { logger_.Emit(LogLevel::Debug, "Blob not found {}", id); @@ -124,17 +123,17 @@ class ObjectCAS { }; [[nodiscard]] auto CreateDigest(std::string const& bytes) const noexcept - -> std::optional<bazel_re::Digest> { + -> std::optional<ArtifactDigest> { return ArtifactDigest::Create<kType>(hash_function_, bytes); } [[nodiscard]] auto CreateDigest(std::filesystem::path const& file_path) - const noexcept -> std::optional<bazel_re::Digest> { + const noexcept -> std::optional<ArtifactDigest> { return ArtifactDigest::CreateFromFile<kType>(hash_function_, file_path); } [[nodiscard]] auto IsAvailable( - bazel_re::Digest const& digest, + ArtifactDigest const& digest, std::filesystem::path const& path) const noexcept -> bool { try { return std::invoke(exists_.get(), digest, path); @@ -160,9 +159,9 @@ class ObjectCAS { /// \brief Store blob from unspecified data to storage. template <class T> [[nodiscard]] auto StoreBlob(T const& data, bool is_owner) const noexcept - -> std::optional<bazel_re::Digest> { + -> std::optional<ArtifactDigest> { if (auto digest = CreateDigest(data)) { - auto id = NativeSupport::Unprefix(digest->hash()); + auto const& id = digest->hash(); if (IsAvailable(*digest, file_store_.GetPath(id))) { return digest; } |