Skip to content

Commit

Permalink
Fix new line printing for unfinished Total progress bar
Browse files Browse the repository at this point in the history
Previously the new line was always printed resulting in excessive empty
line which was visible for example during the downloading packages phase
of an update:
```
[  1/109] kernel-modules-0:6.13.0-0.rc1.20241202gite70140ba0d2b.14.fc42.x86_64                                                                         7% [=                 ] | 781.3 KiB/s |   4.9 MiB | -01m18s
[  2/109] kernel-core-0:6.13.0-0.rc1.20241202gite70140ba0d2b.14.fc42.x86_64                                                                            8% [==                ] | 381.1 KiB/s |   1.5 MiB | -00m45s
[  3/109] kernel-modules-core-0:6.13.0-0.rc1.20241202gite70140ba0d2b.14.fc42.x86_64                                                                    3% [=                 ] | 355.8 KiB/s |   1.2 MiB | -01m47s
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[  0/109] Total                                                                                                                                        3% [=                 ] |   1.5 MiB/s |   7.6 MiB | -02m05s

```
(last line is empty)

This was introduced recently in PR #1805
  • Loading branch information
kontura authored and m-blaha committed Dec 5, 2024
1 parent c97ba06 commit 6e02555
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libdnf5-cli/progressbar/multi_progress_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,12 @@ std::ostream & operator<<(std::ostream & stream, MultiProgressBar & mbar) {
}

text_buffer << mbar.total;
text_buffer << std::endl;
mbar.num_of_lines_to_clear += 3;
mbar.num_of_lines_to_clear += 2;
if (mbar.total.is_finished()) {
text_buffer << std::endl;
} else {
mbar.line_printed = true;
}
}

stream << text_buffer.str(); // Single syscall to output all commands
Expand Down

0 comments on commit 6e02555

Please sign in to comment.