diff --git a/repertory/librepertory/src/file_manager/ring_buffer_open_file.cpp b/repertory/librepertory/src/file_manager/ring_buffer_open_file.cpp index 65dc17d9..bede1aed 100644 --- a/repertory/librepertory/src/file_manager/ring_buffer_open_file.cpp +++ b/repertory/librepertory/src/file_manager/ring_buffer_open_file.cpp @@ -210,7 +210,7 @@ auto ring_buffer_open_file::download_chunk(std::size_t chunk, bool skip_active) chunk_lock.lock(); if (res == api_error::success) { auto progress = - (static_cast(chunk) / static_cast(total_chunks_)) * + (static_cast(chunk + 1U) / static_cast(total_chunks_)) * 100.0; event_system::instance().raise(fsi_.api_path, source_path_, progress); diff --git a/repertory/repertory_test/src/ring_buffer_open_file_test.cpp b/repertory/repertory_test/src/ring_buffer_open_file_test.cpp index 67024c81..d8d0f919 100644 --- a/repertory/repertory_test/src/ring_buffer_open_file_test.cpp +++ b/repertory/repertory_test/src/ring_buffer_open_file_test.cpp @@ -393,15 +393,15 @@ TEST_F(ring_buffer_open_file_test, read_full_file_in_reverse) { EXPECT_TRUE(nf2); auto to_read = fsi.size; - std::size_t chunk = rb.get_total_chunks() - 1u; - while (to_read) { + std::size_t chunk = rb.get_total_chunks() - 1U; + while (to_read > 0U) { data_buffer data{}; EXPECT_EQ(api_error::success, rb.read(test_chunk_size, chunk * test_chunk_size, data)); std::size_t bytes_written{}; EXPECT_TRUE(nf2.write(data, chunk * test_chunk_size, &bytes_written)); - chunk--; + --chunk; to_read -= data.size(); } nf2.close();