summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/common/repository_config.cpp2
-rw-r--r--src/buildtool/main/main.cpp3
-rw-r--r--src/buildtool/serve_api/remote/target_client.cpp4
-rw-r--r--src/buildtool/serve_api/serve_service/source_tree.cpp9
-rw-r--r--src/buildtool/serve_api/serve_service/target.cpp15
-rw-r--r--src/buildtool/storage/fs_utils.cpp3
-rw-r--r--src/buildtool/storage/local_cas.hpp8
-rw-r--r--src/buildtool/storage/local_cas.tpp10
-rw-r--r--src/buildtool/storage/target_cache.tpp7
9 files changed, 25 insertions, 36 deletions
diff --git a/src/buildtool/common/repository_config.cpp b/src/buildtool/common/repository_config.cpp
index caf0d2bf..52694d0b 100644
--- a/src/buildtool/common/repository_config.cpp
+++ b/src/buildtool/common/repository_config.cpp
@@ -46,7 +46,7 @@ auto RepositoryConfig::RepositoryKey(Storage const& storage,
unique, storage.GetHashFunction())) {
auto const& cas = storage.CAS();
if (auto digest = cas.StoreBlob(graph->dump(2))) {
- return ArtifactDigest{*digest}.hash();
+ return digest->hash();
}
}
return std::nullopt;
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 1cf9901b..ee118f4a 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -248,8 +248,7 @@ void StoreTargetCacheShard(
std::exit(kExitFailure);
}
[[maybe_unused]] auto id = storage.CAS().StoreBlob(*backend_description);
- EnsuresAudit(id and ArtifactDigest{*id}.hash() ==
- storage_config.backend_description_id);
+ EnsuresAudit(id and id->hash() == storage_config.backend_description_id);
}
#endif // BOOTSTRAP_BUILD_TOOL
diff --git a/src/buildtool/serve_api/remote/target_client.cpp b/src/buildtool/serve_api/remote/target_client.cpp
index 4d11fe84..c3f636f4 100644
--- a/src/buildtool/serve_api/remote/target_client.cpp
+++ b/src/buildtool/serve_api/remote/target_client.cpp
@@ -93,8 +93,8 @@ auto TargetClient::ServeTarget(const TargetCacheKey& key,
fmt::format("Failed to store blob {} to local cas",
dispatch_list.dump(2))};
}
- auto const& dispatch_info = Artifact::ObjectInfo{
- .digest = ArtifactDigest{*dispatch_dgst}, .type = ObjectType::File};
+ auto const dispatch_info = Artifact::ObjectInfo{.digest = *dispatch_dgst,
+ .type = ObjectType::File};
if (not apis_.local->RetrieveToCas({dispatch_info}, *apis_.remote)) {
return serve_target_result_t{
std::in_place_index<1>,
diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp
index 8b049691..d2ba33f6 100644
--- a/src/buildtool/serve_api/serve_service/source_tree.cpp
+++ b/src/buildtool/serve_api/serve_service/source_tree.cpp
@@ -24,7 +24,6 @@
#include "src/buildtool/common/artifact.hpp"
#include "src/buildtool/common/artifact_digest.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
-#include "src/buildtool/compatibility/native_support.hpp"
#include "src/buildtool/crypto/hash_function.hpp"
#include "src/buildtool/execution_api/git/git_api.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
@@ -986,7 +985,7 @@ auto SourceTreeService::ServeDistdirTree(
return ::grpc::Status::OK;
}
blob_found = true;
- blob_digest = NativeSupport::Unprefix(stored_blob->hash());
+ blob_digest = stored_blob->hash();
}
else {
if (res.error() == GitLookupError::Fatal) {
@@ -1016,8 +1015,7 @@ auto SourceTreeService::ServeDistdirTree(
return ::grpc::Status::OK;
}
blob_found = true;
- blob_digest =
- NativeSupport::Unprefix(stored_blob->hash());
+ blob_digest = stored_blob->hash();
break;
}
if (res.error() == GitLookupError::Fatal) {
@@ -1103,8 +1101,7 @@ auto SourceTreeService::ServeDistdirTree(
// get hash from raw_id
auto tree_id = ToHexString(tree->first);
// add tree to local CAS
- auto tree_digest = cas.StoreTree(tree->second);
- if (not tree_digest) {
+ if (not cas.StoreTree(tree->second)) {
logger_->Emit(LogLevel::Error,
"Failed to store distdir tree {} to local CAS",
tree_id);
diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp
index ea0c36c9..85a01fd1 100644
--- a/src/buildtool/serve_api/serve_service/target.cpp
+++ b/src/buildtool/serve_api/serve_service/target.cpp
@@ -104,8 +104,7 @@ auto TargetService::HandleFailureLog(
}
// upload log blob to remote
if (not apis_.local->RetrieveToCas(
- {Artifact::ObjectInfo{.digest = ArtifactDigest{*digest},
- .type = ObjectType::File}},
+ {Artifact::ObjectInfo{.digest = *digest, .type = ObjectType::File}},
*apis_.remote)) {
auto msg =
fmt::format("Failed to upload to remote CAS the failed {} log {}",
@@ -203,10 +202,9 @@ auto TargetService::ServeTarget(
}
// get a target cache instance with the correct computed shard
- auto shard =
- remote_config->remote_address
- ? std::make_optional(ArtifactDigest(*execution_backend_dgst).hash())
- : std::nullopt;
+ auto shard = remote_config->remote_address
+ ? std::make_optional(execution_backend_dgst->hash())
+ : std::nullopt;
auto const& tc = local_context_.storage->TargetCache().WithShard(shard);
auto const& tc_key =
TargetCacheKey{{target_cache_key_digest, ObjectType::File}};
@@ -918,14 +916,13 @@ auto TargetService::ServeTargetDescription(
if (auto dgst =
local_context_.storage->CAS().StoreBlob(description_str,
/*is_executable=*/false)) {
- auto const& artifact_dgst = ArtifactDigest{*dgst};
if (not apis_.local->RetrieveToCas(
- {Artifact::ObjectInfo{.digest = artifact_dgst,
+ {Artifact::ObjectInfo{.digest = *dgst,
.type = ObjectType::File}},
*apis_.remote)) {
auto error_msg = fmt::format(
"Failed to upload to remote cas the description blob {}",
- artifact_dgst.hash());
+ dgst->hash());
logger_->Emit(LogLevel::Error, "{}", error_msg);
return ::grpc::Status{::grpc::StatusCode::UNAVAILABLE, error_msg};
}
diff --git a/src/buildtool/storage/fs_utils.cpp b/src/buildtool/storage/fs_utils.cpp
index 62adf1e9..171a5d1c 100644
--- a/src/buildtool/storage/fs_utils.cpp
+++ b/src/buildtool/storage/fs_utils.cpp
@@ -127,8 +127,7 @@ auto AddToCAS(Storage const& storage, std::string const& data) noexcept
// get file CAS instance
auto const& cas = storage.CAS();
// write to cas
- auto digest = cas.StoreBlob(data);
- if (digest) {
+ if (auto digest = cas.StoreBlob(data)) {
return cas.BlobPath(*digest, /*is_executable=*/false);
}
return std::nullopt;
diff --git a/src/buildtool/storage/local_cas.hpp b/src/buildtool/storage/local_cas.hpp
index 4fc11d4a..1b9bed48 100644
--- a/src/buildtool/storage/local_cas.hpp
+++ b/src/buildtool/storage/local_cas.hpp
@@ -95,7 +95,7 @@ class LocalCAS {
template <bool kOwner = false>
[[nodiscard]] auto StoreBlob(std::filesystem::path const& file_path,
bool is_executable) const noexcept
- -> std::optional<bazel_re::Digest> {
+ -> std::optional<ArtifactDigest> {
return is_executable ? cas_exec_.StoreBlobFromFile(file_path, kOwner)
: cas_file_.StoreBlobFromFile(file_path, kOwner);
}
@@ -106,7 +106,7 @@ class LocalCAS {
/// \returns Digest of the stored blob or nullopt otherwise.
[[nodiscard]] auto StoreBlob(std::string const& bytes,
bool is_executable = false) const noexcept
- -> std::optional<bazel_re::Digest> {
+ -> std::optional<ArtifactDigest> {
return is_executable ? cas_exec_.StoreBlobFromBytes(bytes)
: cas_file_.StoreBlobFromBytes(bytes);
}
@@ -117,7 +117,7 @@ class LocalCAS {
/// \returns Digest of the stored tree or nullopt otherwise.
template <bool kOwner = false>
[[nodiscard]] auto StoreTree(std::filesystem::path const& file_path)
- const noexcept -> std::optional<bazel_re::Digest> {
+ const noexcept -> std::optional<ArtifactDigest> {
return cas_tree_.StoreBlobFromFile(file_path, kOwner);
}
@@ -125,7 +125,7 @@ class LocalCAS {
/// \param bytes The bytes to create the tree from.
/// \returns Digest of the stored tree or nullopt otherwise.
[[nodiscard]] auto StoreTree(std::string const& bytes) const noexcept
- -> std::optional<bazel_re::Digest> {
+ -> std::optional<ArtifactDigest> {
return cas_tree_.StoreBlobFromBytes(bytes);
}
diff --git a/src/buildtool/storage/local_cas.tpp b/src/buildtool/storage/local_cas.tpp
index 7f44b0c2..bf208ca9 100644
--- a/src/buildtool/storage/local_cas.tpp
+++ b/src/buildtool/storage/local_cas.tpp
@@ -413,12 +413,12 @@ auto LocalCAS<kDoGlobalUplink>::Splice(ArtifactDigest const& digest,
static constexpr bool kOwner = true;
auto const stored_digest = kIsTree ? StoreTree<kOwner>(file_path)
: StoreBlob<kOwner>(file_path, kIsExec);
- if (stored_digest) {
- return ArtifactDigest{std::move(*stored_digest)};
+ if (not stored_digest) {
+ return unexpected{LargeObjectError{
+ LargeObjectErrorCode::Internal,
+ fmt::format("could not splice {}", digest.hash())}};
}
- return unexpected{
- LargeObjectError{LargeObjectErrorCode::Internal,
- fmt::format("could not splice {}", digest.hash())}};
+ return *std::move(stored_digest);
}
#endif // INCLUDED_SRC_BUILDTOOL_STORAGE_LOCAL_CAS_TPP
diff --git a/src/buildtool/storage/target_cache.tpp b/src/buildtool/storage/target_cache.tpp
index 502c346a..4026238f 100644
--- a/src/buildtool/storage/target_cache.tpp
+++ b/src/buildtool/storage/target_cache.tpp
@@ -31,9 +31,7 @@ auto TargetCache<kDoGlobalUplink>::Store(
return false;
}
if (auto digest = cas_.StoreBlob(value.ToJson().dump(2))) {
- auto data =
- Artifact::ObjectInfo{ArtifactDigest{*digest}, ObjectType::File}
- .ToString();
+ auto data = Artifact::ObjectInfo{*digest, ObjectType::File}.ToString();
logger_->Emit(LogLevel::Debug,
"Adding entry for key {} as {}",
key.Id().ToString(),
@@ -58,8 +56,7 @@ auto TargetCache<kDoGlobalUplink>::ComputeKey(
{"effective_config", effective_config.ToString()}};
if (auto target_key =
cas_.StoreBlob(target_desc.dump(2), /*is_executable=*/false)) {
- return TargetCacheKey{
- {ArtifactDigest{*target_key}, ObjectType::File}};
+ return TargetCacheKey{{*target_key, ObjectType::File}};
}
} catch (std::exception const& ex) {
logger_->Emit(LogLevel::Error,