Skip to content

Commit

Permalink
fix: Progress reader updates the output only when progressing
Browse files Browse the repository at this point in the history
Due to a bug in the logic, the progress was being updated after every
block, even if the percentage number was not changing. This made the
reading/writing of Artifacts slow and noisy.

Changelog: Title
Ticket: MEN-7159

Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
  • Loading branch information
lluiscampos committed Aug 26, 2024
1 parent eae7540 commit 23d2616
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/mender-update/progress_reader/progress_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ expected::ExpectedSize Reader::Read(
int percentage = (bytes_read_ / static_cast<float>(tot_size_)) * 100;
if (percentage > last_percentage) {
cerr << "\r" << percentage << "%";
last_percentage = percentage;
}
}
return exp_read;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ TEST(ProgressReaderTests, RegularRead) {

std::string output = testing::internal::GetCapturedStderr();

EXPECT_EQ(output, "\r0%\r5%\r5%\r25%\r90%\r100%");
EXPECT_EQ(output, "\r0%\r5%\r25%\r90%\r100%");
}

0 comments on commit 23d2616

Please sign in to comment.