ring buffer selection fixes
This commit is contained in:
parent
086feaf7a5
commit
18b865bbea
@ -407,17 +407,23 @@ auto file_manager::open(
|
||||
}
|
||||
|
||||
if (not closeable_file) {
|
||||
auto buffer_directory =
|
||||
utils::path::combine(config_.get_data_directory(), {"buffer"});
|
||||
auto chunk_size =
|
||||
utils::encryption::encrypting_reader::get_data_chunk_size();
|
||||
auto ring_size =
|
||||
(static_cast<std::uint64_t>(config_.get_ring_buffer_file_size() *
|
||||
1024UL * 1024UL) /
|
||||
chunk_size);
|
||||
auto buffer_directory{
|
||||
utils::path::combine(config_.get_data_directory(), {"buffer"}),
|
||||
};
|
||||
|
||||
auto chunk_size{
|
||||
utils::encryption::encrypting_reader::get_data_chunk_size(),
|
||||
};
|
||||
|
||||
auto ring_buffer_file_size{
|
||||
static_cast<std::uint64_t>(config_.get_ring_buffer_file_size()) *
|
||||
1024UL * 1024UL * 1024UL,
|
||||
};
|
||||
|
||||
auto ring_size{ring_buffer_file_size / chunk_size};
|
||||
|
||||
const auto get_download_type =
|
||||
[this, &buffer_directory, &chunk_size, &fsi,
|
||||
[this, &buffer_directory, &chunk_size, &fsi, &ring_buffer_file_size,
|
||||
&ring_size](download_type type) -> download_type {
|
||||
if (fsi.size == 0U) {
|
||||
return download_type::fallback;
|
||||
@ -441,15 +447,15 @@ auto file_manager::open(
|
||||
}
|
||||
|
||||
if (not utils::file::directory{buffer_directory}.create_directory()) {
|
||||
utils::error::raise_api_path_error(
|
||||
function_name, fsi.api_path, utils::get_last_error_code(),
|
||||
utils::error::raise_error(
|
||||
function_name, utils::get_last_error_code(),
|
||||
fmt::format("failed to create buffer directory|sp|{}",
|
||||
buffer_directory));
|
||||
return download_type::direct;
|
||||
}
|
||||
|
||||
auto free_space = utils::file::get_free_drive_space(buffer_directory);
|
||||
if (config_.get_ring_buffer_file_size() < free_space) {
|
||||
if (ring_buffer_file_size < free_space) {
|
||||
return download_type::ring_buffer;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user