This commit is contained in:
@ -78,7 +78,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
void download_chunk(std::size_t chunk, bool skip_active, bool should_reset);
|
void download_chunk(std::size_t chunk, bool skip_active, bool should_reset);
|
||||||
|
|
||||||
void download_range(std::size_t start_chunk, std::size_t end_chunk,
|
void download_range(std::size_t begin_chunk, std::size_t end_chunk,
|
||||||
bool should_reset);
|
bool should_reset);
|
||||||
|
|
||||||
void set_modified();
|
void set_modified();
|
||||||
|
@ -311,9 +311,9 @@ 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 begin_chunk, std::size_t end_chunk,
|
||||||
bool should_reset) {
|
bool should_reset) {
|
||||||
for (std::size_t chunk = start_chunk;
|
for (std::size_t chunk = begin_chunk;
|
||||||
(get_api_error() == api_error::success) && (chunk <= end_chunk);
|
(get_api_error() == api_error::success) && (chunk <= end_chunk);
|
||||||
++chunk) {
|
++chunk) {
|
||||||
download_chunk(chunk, false, should_reset);
|
download_chunk(chunk, false, should_reset);
|
||||||
@ -487,13 +487,13 @@ auto open_file::read(std::size_t read_size, std::uint64_t read_offset,
|
|||||||
return read_from_source();
|
return read_from_source();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto start_chunk = static_cast<std::size_t>(read_offset / chunk_size_);
|
auto begin_chunk = static_cast<std::size_t>(read_offset / chunk_size_);
|
||||||
auto end_chunk =
|
auto end_chunk =
|
||||||
static_cast<std::size_t>((read_size + read_offset) / chunk_size_);
|
static_cast<std::size_t>((read_size + read_offset) / chunk_size_);
|
||||||
|
|
||||||
update_background_reader(start_chunk);
|
update_background_reader(begin_chunk);
|
||||||
|
|
||||||
download_range(start_chunk, end_chunk, true);
|
download_range(begin_chunk, end_chunk, true);
|
||||||
if (get_api_error() != api_error::success) {
|
if (get_api_error() != api_error::success) {
|
||||||
return get_api_error();
|
return get_api_error();
|
||||||
}
|
}
|
||||||
@ -624,13 +624,13 @@ auto open_file::write(std::uint64_t write_offset, const data_buffer &data,
|
|||||||
return api_error::download_stopped;
|
return api_error::download_stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto start_chunk = static_cast<std::size_t>(write_offset / chunk_size_);
|
auto begin_chunk = static_cast<std::size_t>(write_offset / chunk_size_);
|
||||||
auto end_chunk =
|
auto end_chunk =
|
||||||
static_cast<std::size_t>((write_offset + data.size()) / chunk_size_);
|
static_cast<std::size_t>((write_offset + data.size()) / chunk_size_);
|
||||||
|
|
||||||
update_background_reader(start_chunk);
|
update_background_reader(begin_chunk);
|
||||||
|
|
||||||
download_range(start_chunk, std::min(get_read_state().size() - 1U, end_chunk),
|
download_range(begin_chunk, std::min(get_read_state().size() - 1U, end_chunk),
|
||||||
true);
|
true);
|
||||||
if (get_api_error() != api_error::success) {
|
if (get_api_error() != api_error::success) {
|
||||||
return get_api_error();
|
return get_api_error();
|
||||||
|
Reference in New Issue
Block a user