summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/file_system/object_cas.hpp21
-rw-r--r--src/buildtool/storage/local_cas.hpp8
-rw-r--r--src/buildtool/storage/local_cas.tpp10
3 files changed, 21 insertions, 18 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;
}
diff --git a/src/buildtool/storage/local_cas.hpp b/src/buildtool/storage/local_cas.hpp
index 86bfc0e4..3097780a 100644
--- a/src/buildtool/storage/local_cas.hpp
+++ b/src/buildtool/storage/local_cas.hpp
@@ -149,8 +149,9 @@ class LocalCAS {
[[nodiscard]] auto BlobPathNoSync(bazel_re::Digest const& digest,
bool is_executable) const noexcept
-> std::optional<std::filesystem::path> {
- return is_executable ? cas_exec_.BlobPath(digest)
- : cas_file_.BlobPath(digest);
+ auto const a_digest = static_cast<ArtifactDigest>(digest);
+ return is_executable ? cas_exec_.BlobPath(a_digest)
+ : cas_file_.BlobPath(a_digest);
}
/// \brief Split a blob into chunks.
@@ -181,7 +182,8 @@ class LocalCAS {
/// \returns Path to the tree if found or nullopt otherwise.
[[nodiscard]] auto TreePath(bazel_re::Digest const& digest) const noexcept
-> std::optional<std::filesystem::path> {
- return cas_tree_.BlobPath(digest);
+ auto const a_digest = static_cast<ArtifactDigest>(digest);
+ return cas_tree_.BlobPath(a_digest);
}
/// \brief Split a tree into chunks.
diff --git a/src/buildtool/storage/local_cas.tpp b/src/buildtool/storage/local_cas.tpp
index 3f6af365..fb828617 100644
--- a/src/buildtool/storage/local_cas.tpp
+++ b/src/buildtool/storage/local_cas.tpp
@@ -113,13 +113,14 @@ auto LocalCAS<kDoGlobalUplink>::LocalUplinkGitTree(
bazel_re::Digest const& digest,
bool splice_result) const noexcept -> bool {
// Determine tree path in latest generation.
- auto tree_path_latest = latest.cas_tree_.BlobPath(digest);
+ auto const a_digest = static_cast<ArtifactDigest>(digest);
+ auto tree_path_latest = latest.cas_tree_.BlobPath(a_digest);
if (tree_path_latest) {
return true;
}
// Determine tree path of given generation.
- auto tree_path = cas_tree_.BlobPath(digest);
+ auto tree_path = cas_tree_.BlobPath(a_digest);
std::optional<LargeObject> spliced;
if (not tree_path) {
spliced = TrySplice<ObjectType::Tree>(digest);
@@ -213,8 +214,9 @@ auto LocalCAS<kDoGlobalUplink>::LocalUplinkBazelDirectory(
return true;
}
+ auto const a_digest = static_cast<ArtifactDigest>(digest);
// Determine bazel directory path of given generation.
- auto dir_path = cas_tree_.BlobPath(digest);
+ auto dir_path = cas_tree_.BlobPath(a_digest);
std::optional<LargeObject> spliced;
if (not dir_path) {
spliced = TrySplice<ObjectType::Tree>(digest);
@@ -244,7 +246,7 @@ auto LocalCAS<kDoGlobalUplink>::LocalUplinkBazelDirectory(
}
// Determine bazel directory path in latest generation.
- auto dir_path_latest = latest.cas_tree_.BlobPath(digest);
+ auto dir_path_latest = latest.cas_tree_.BlobPath(a_digest);
if (spliced) {
// Uplink the large entry afterwards: