diff --git a/repertory/librepertory/src/file_manager/open_file.cpp b/repertory/librepertory/src/file_manager/open_file.cpp index ae157c34..3903f392 100644 --- a/repertory/librepertory/src/file_manager/open_file.cpp +++ b/repertory/librepertory/src/file_manager/open_file.cpp @@ -301,10 +301,14 @@ auto open_file::native_operation( } if (is_empty_file || (read_state_.size() != (last_chunk + 1U))) { + auto old_size = read_state_.size(); read_state_.resize(is_empty_file ? 0U : last_chunk + 1U); if (not is_empty_file) { - read_state_[last_chunk] = true; + for (std::size_t chunk_index = old_size; chunk_index <= last_chunk; + ++chunk_index) { + read_state_.set(chunk_index); + } } last_chunk_size_ = static_cast( @@ -570,11 +574,6 @@ auto open_file::write(std::uint64_t write_offset, const data_buffer &data, return api_error::os_error; } - for (std::size_t chunk_index = start_chunk_index; - chunk_index <= end_chunk_index; ++chunk_index) { - read_state_.set(chunk_idx); - } - reset_timeout(); return api_error::success; });