This commit is contained in:
parent
ab07d7e192
commit
2952cc8373
@ -309,11 +309,10 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active,
|
|||||||
|
|
||||||
void open_file::download_range(std::size_t start_chunk, std::size_t end_chunk,
|
void open_file::download_range(std::size_t start_chunk, std::size_t end_chunk,
|
||||||
bool should_reset) {
|
bool should_reset) {
|
||||||
for (std::size_t chunk = start_chunk; chunk <= end_chunk; ++chunk) {
|
for (std::size_t chunk = start_chunk;
|
||||||
|
(get_api_error() == api_error::success) && (chunk <= end_chunk);
|
||||||
|
++chunk) {
|
||||||
download_chunk(chunk, false, should_reset);
|
download_chunk(chunk, false, should_reset);
|
||||||
if (get_api_error() != api_error::success) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,7 +557,10 @@ void open_file::update_background_reader(std::size_t read_chunk) {
|
|||||||
recur_mutex_lock reader_lock(file_mtx_);
|
recur_mutex_lock reader_lock(file_mtx_);
|
||||||
read_chunk_ = read_chunk;
|
read_chunk_ = read_chunk;
|
||||||
|
|
||||||
if (not reader_thread_ && not stop_requested_) {
|
if (reader_thread_ || stop_requested_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
reader_thread_ = std::make_unique<std::thread>([this]() {
|
reader_thread_ = std::make_unique<std::thread>([this]() {
|
||||||
std::size_t next_chunk{};
|
std::size_t next_chunk{};
|
||||||
while (not stop_requested_) {
|
while (not stop_requested_) {
|
||||||
@ -576,17 +578,15 @@ void open_file::update_background_reader(std::size_t read_chunk) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
next_chunk = read_chunk_ = ((read_chunk_ + 1U) >= read_state_.size())
|
next_chunk = read_chunk_ =
|
||||||
? 0U
|
((read_chunk_ + 1U) >= read_state_.size()) ? 0U : read_chunk_ + 1U;
|
||||||
: read_chunk_ + 1U;
|
} while ((next_chunk != 0U) &&
|
||||||
} while ((next_chunk != 0U) && (active_downloads_.find(next_chunk) !=
|
(active_downloads_.find(next_chunk) != active_downloads_.end()));
|
||||||
active_downloads_.end()));
|
|
||||||
|
|
||||||
file_lock.unlock();
|
file_lock.unlock();
|
||||||
download_chunk(next_chunk, true, false);
|
download_chunk(next_chunk, true, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto open_file::write(std::uint64_t write_offset, const data_buffer &data,
|
auto open_file::write(std::uint64_t write_offset, const data_buffer &data,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user