2 Commits

Author SHA1 Message Date
4a203ebf47 refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
2024-12-20 21:03:16 -06:00
f260f1d50a refactor 2024-12-20 20:57:29 -06:00

View File

@ -108,13 +108,14 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
if ((get_api_error() == api_error::success) && (chunk < read_state_.size()) && if ((get_api_error() == api_error::success) && (chunk < read_state_.size()) &&
not read_state_[chunk]) { not read_state_[chunk]) {
if (active_downloads_.find(chunk) != active_downloads_.end()) { if (active_downloads_.find(chunk) != active_downloads_.end()) {
if (not skip_active) { if (skip_active) {
auto active_download = active_downloads_.at(chunk); return;
download_lock.unlock();
active_download->wait();
} }
auto active_download = active_downloads_.at(chunk);
download_lock.unlock();
active_download->wait();
return; return;
} }
@ -558,17 +559,18 @@ void open_file::update_background_reader(std::size_t read_chunk) {
} }
io_thread_notify_.notify_all(); io_thread_notify_.notify_all();
io_lock.unlock(); io_lock.unlock();
} else { continue;
do {
next_chunk = read_chunk_ =
((read_chunk_ + 1U) >= read_state_.size()) ? 0U
: read_chunk_ + 1U;
} while ((next_chunk != 0U) && (active_downloads_.find(next_chunk) !=
active_downloads_.end()));
file_lock.unlock();
download_chunk(next_chunk, true, false);
} }
do {
next_chunk = read_chunk_ = ((read_chunk_ + 1U) >= read_state_.size())
? 0U
: read_chunk_ + 1U;
} while ((next_chunk != 0U) && (active_downloads_.find(next_chunk) !=
active_downloads_.end()));
file_lock.unlock();
download_chunk(next_chunk, true, false);
} }
}); });
} }