refactor
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2024-12-27 15:08:14 -06:00
parent 869e271fde
commit e4d8f99d7a
2 changed files with 12 additions and 7 deletions

View File

@ -49,7 +49,9 @@ public:
private: private:
std::string source_path_; std::string source_path_;
data_buffer data_buffer_;
private:
data_buffer read_buffer_;
protected: protected:
[[nodiscard]] auto [[nodiscard]] auto

View File

@ -56,7 +56,7 @@ auto ring_buffer_open_file::can_handle_file(std::uint64_t file_size,
auto ring_buffer_open_file::get_read_buffer(std::size_t /* chunk */) auto ring_buffer_open_file::get_read_buffer(std::size_t /* chunk */)
-> data_buffer & { -> data_buffer & {
return data_buffer_; return read_buffer_;
} }
auto ring_buffer_open_file::on_check_start() -> bool { auto ring_buffer_open_file::on_check_start() -> bool {
@ -113,20 +113,23 @@ void ring_buffer_open_file::on_destroy() {
nf_->close(); nf_->close();
nf_.reset(); nf_.reset();
if (not utils::file::file(get_source_path()).remove()) { if (utils::file::file(get_source_path()).remove()) {
return;
}
utils::error::raise_api_path_error( utils::error::raise_api_path_error(
function_name, get_api_path(), get_source_path(), function_name, get_api_path(), get_source_path(),
utils::get_last_error_code(), "failed to delete file"); utils::get_last_error_code(), "failed to delete file");
}
} }
auto ring_buffer_open_file::use_buffer( auto ring_buffer_open_file::use_buffer(
std::size_t chunk, std::size_t chunk,
std::function<api_error(const data_buffer &data)> func) -> api_error { std::function<api_error(const data_buffer &data)> func) -> api_error {
data_buffer buffer; data_buffer buffer;
buffer.resize(get_chunk_size());
auto res = do_io([&]() -> api_error { auto res = do_io([&]() -> api_error {
std::size_t bytes_read{}; std::size_t bytes_read{};
buffer.resize(get_chunk_size());
auto result = auto result =
nf_->read(buffer, (chunk % get_read_state_size()) * get_chunk_size(), nf_->read(buffer, (chunk % get_read_state_size()) * get_chunk_size(),
&bytes_read) &bytes_read)