blob: 353258f5b596d264d91b7ceb5ae3545b4485d82d [file] [log] [blame]
// Copyright 2022 The Pigweed Authors
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#include "pw_transfer/internal/server_context.h"
#include "pw_assert/check.h"
#include "pw_log/log.h"
#include "pw_status/try.h"
#include "pw_transfer/internal/chunk.h"
#include "pw_transfer/transfer.pwpb.h"
#include "pw_varint/varint.h"
namespace pw::transfer::internal {
Status ServerContext::FinalCleanup(const Status status) {
// If no handler is set, then the Prepare call failed. Nothing to do.
if (handler_ == nullptr) {
return OkStatus();
Handler& handler = *handler_;
handler_ = nullptr;
if (type() == TransferType::kTransmit) {
return OkStatus();
if (Status finalized = handler.FinalizeWrite(status); !finalized.ok()) {
"FinalizeWrite() for transfer %u failed with status %u; aborting with "
return Status::DataLoss();
return OkStatus();
} // namespace pw::transfer::internal