summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/execution_service/execution_server.cpp
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-07-30 17:28:03 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-08-07 14:43:19 +0200
commit665147668bb8d8c712bffc078f4781bac9f30e99 (patch)
treed1e65361f66cc425f5ce947a635ba856671500f1 /src/buildtool/execution_api/execution_service/execution_server.cpp
parent58790b8d0d276379c4d7c2bca0405f402e5f0e08 (diff)
downloadjustbuild-665147668bb8d8c712bffc078f4781bac9f30e99.tar.gz
ExecutionServer: remove redundant scopes
Diffstat (limited to 'src/buildtool/execution_api/execution_service/execution_server.cpp')
-rw-r--r--src/buildtool/execution_api/execution_service/execution_server.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp
index 84a5e53f..94b66333 100644
--- a/src/buildtool/execution_api/execution_service/execution_server.cpp
+++ b/src/buildtool/execution_api/execution_service/execution_server.cpp
@@ -41,7 +41,7 @@ auto ExecutionServiceImpl::GetAction(::bazel_re::ExecuteRequest const* request)
const noexcept -> std::pair<std::optional<::bazel_re::Action>,
std::optional<std::string>> {
// get action description
- if (auto error_msg = IsAHash(request->action_digest().hash()); error_msg) {
+ if (auto error_msg = IsAHash(request->action_digest().hash())) {
logger_.Emit(LogLevel::Error, "{}", *error_msg);
return {std::nullopt, *error_msg};
}
@@ -52,18 +52,15 @@ auto ExecutionServiceImpl::GetAction(::bazel_re::ExecuteRequest const* request)
logger_.Emit(LogLevel::Error, "{}", str);
return {std::nullopt, str};
}
+
::bazel_re::Action action{};
- {
- std::ifstream f(*path);
- if (not action.ParseFromIstream(&f)) {
- auto str = fmt::format("failed to parse action from blob {}",
- request->action_digest().hash());
- logger_.Emit(LogLevel::Error, "{}", str);
- return {std::nullopt, str};
- }
+ if (std::ifstream f(*path); not action.ParseFromIstream(&f)) {
+ auto str = fmt::format("failed to parse action from blob {}",
+ request->action_digest().hash());
+ logger_.Emit(LogLevel::Error, "{}", str);
+ return {std::nullopt, std::move(str)};
}
- if (auto error_msg = IsAHash(action.input_root_digest().hash());
- error_msg) {
+ if (auto error_msg = IsAHash(action.input_root_digest().hash())) {
logger_.Emit(LogLevel::Error, "{}", *error_msg);
return {std::nullopt, *error_msg};
}
@@ -83,7 +80,7 @@ auto ExecutionServiceImpl::GetAction(::bazel_re::ExecuteRequest const* request)
auto ExecutionServiceImpl::GetCommand(::bazel_re::Action const& action)
const noexcept -> std::pair<std::optional<::bazel_re::Command>,
std::optional<std::string>> {
- if (auto error_msg = IsAHash(action.command_digest().hash()); error_msg) {
+ if (auto error_msg = IsAHash(action.command_digest().hash())) {
logger_.Emit(LogLevel::Error, "{}", *error_msg);
return {std::nullopt, *error_msg};
}
@@ -96,14 +93,11 @@ auto ExecutionServiceImpl::GetCommand(::bazel_re::Action const& action)
}
::bazel_re::Command c{};
- {
- std::ifstream f(*path);
- if (not c.ParseFromIstream(&f)) {
- auto str = fmt::format("failed to parse command from blob {}",
- action.command_digest().hash());
- logger_.Emit(LogLevel::Error, "{}", str);
- return {std::nullopt, str};
- }
+ if (std::ifstream f(*path); not c.ParseFromIstream(&f)) {
+ auto str = fmt::format("failed to parse command from blob {}",
+ action.command_digest().hash());
+ logger_.Emit(LogLevel::Error, "{}", str);
+ return {std::nullopt, std::move(str)};
}
return {c, std::nullopt};
}
@@ -389,7 +383,7 @@ auto ExecutionServiceImpl::WaitExecution(
::grpc::ServerWriter<::google::longrunning::Operation>* writer)
-> ::grpc::Status {
auto const& hash = request->name();
- if (auto error_msg = IsAHash(hash); error_msg) {
+ if (auto error_msg = IsAHash(hash)) {
logger_.Emit(LogLevel::Error, "{}", *error_msg);
return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, *error_msg};
}