fixes
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2024-12-27 20:36:40 -06:00
parent 9baae9c185
commit 7b98f26d34
6 changed files with 32 additions and 40 deletions

View File

@ -35,7 +35,7 @@ public:
direct_open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
filesystem_item fsi, i_provider &provider);
~direct_open_file() override = default;
~direct_open_file() override;
public:
direct_open_file() = delete;

View File

@ -36,7 +36,7 @@ public:
std::uint8_t chunk_timeout, filesystem_item fsi,
i_provider &provider, std::size_t ring_size);
~ring_buffer_open_file() override = default;
~ring_buffer_open_file() override;
public:
ring_buffer_open_file() = delete;
@ -61,8 +61,6 @@ protected:
on_chunk_downloaded(std::size_t chunk,
const data_buffer &buffer) -> api_error override;
void on_destroy() override;
[[nodiscard]] auto
use_buffer(std::size_t chunk,
std::function<api_error(const data_buffer &buffer)> func)

View File

@ -36,7 +36,7 @@ public:
filesystem_item fsi, i_provider &provider,
std::size_t ring_size, bool disable_io);
~ring_file_base() override;
~ring_file_base() override = default;
public:
static constexpr const auto min_ring_size{5U};
@ -90,8 +90,6 @@ protected:
return api_error::success;
}
virtual void on_destroy() {}
[[nodiscard]] virtual auto
use_buffer(std::size_t chunk,
std::function<api_error(const data_buffer &buffer)> func)

View File

@ -28,6 +28,8 @@ direct_open_file::direct_open_file(std::uint64_t chunk_size,
: ring_file_base(chunk_size, chunk_timeout, fsi, provider, min_ring_size,
true) {}
direct_open_file::~direct_open_file() { close(); }
auto direct_open_file::handle_read_buffer(
std::size_t chunk,
std::function<api_error(data_buffer &data)> func) -> api_error {

View File

@ -40,6 +40,25 @@ ring_buffer_open_file::ring_buffer_open_file(std::string buffer_directory,
utils::create_uuid_string(),
})) {}
ring_buffer_open_file::~ring_buffer_open_file() {
REPERTORY_USES_FUNCTION_NAME();
close();
if (nf_) {
nf_->close();
nf_.reset();
}
if (utils::file::file(get_source_path()).remove()) {
return;
}
utils::error::raise_api_path_error(
function_name, get_api_path(), get_source_path(),
utils::get_last_error_code(), "failed to delete file");
}
auto ring_buffer_open_file::handle_read_buffer(
std::size_t /* chunk */,
std::function<api_error(data_buffer &data)> func) -> api_error {
@ -91,25 +110,6 @@ auto ring_buffer_open_file::on_chunk_downloaded(
});
}
void ring_buffer_open_file::on_destroy() {
REPERTORY_USES_FUNCTION_NAME();
if (not nf_) {
return;
}
nf_->close();
nf_.reset();
if (utils::file::file(get_source_path()).remove()) {
return;
}
utils::error::raise_api_path_error(
function_name, get_api_path(), get_source_path(),
utils::get_last_error_code(), "failed to delete file");
}
auto ring_buffer_open_file::use_buffer(
std::size_t chunk,
std::function<api_error(const data_buffer &data)> func) -> api_error {

View File

@ -59,19 +59,6 @@ ring_file_base::ring_file_base(std::uint64_t chunk_size,
ring_state_.set(0U, ring_state_.size(), false);
}
ring_file_base::~ring_file_base() {
REPERTORY_USES_FUNCTION_NAME();
close();
on_destroy();
if (reader_thread_) {
reader_thread_->join();
reader_thread_.reset();
}
}
auto ring_file_base::can_handle_file(std::uint64_t file_size,
std::size_t chunk_size,
std::size_t ring_size) -> bool {
@ -107,7 +94,14 @@ auto ring_file_base::close() -> bool {
chunk_notify_.notify_all();
chunk_lock.unlock();
return open_file_base::close();
auto ret = open_file_base::close();
if (reader_thread_) {
reader_thread_->join();
reader_thread_.reset();
}
return ret;
}
auto ring_file_base::download_chunk(std::size_t chunk,