copy: calculate bytes per second while copying, and pass to progress info

Also, show it in import-fs/repart.
This commit is contained in:
Lennart Poettering
2025-09-17 19:48:08 +01:00
committed by Luca Boccassi
parent e566236fc1
commit acd4943528
5 changed files with 42 additions and 16 deletions
+20 -9
View File
@@ -5377,7 +5377,7 @@ static int partition_format_verity_sig(Context *context, Partition *p) {
return 0;
}
static int progress_bytes(uint64_t n_bytes, void *userdata) {
static int progress_bytes(uint64_t n_bytes, uint64_t bps, void *userdata) {
Partition *p = ASSERT_PTR(userdata);
unsigned percent;
@@ -5395,14 +5395,25 @@ static int progress_bytes(uint64_t n_bytes, void *userdata) {
if (!ratelimit_below(&p->progress_ratelimit))
return 0;
(void) draw_progress_barf(
percent,
"%s %s %s %s/%s",
strna(p->copy_blocks_path),
glyph(GLYPH_ARROW_RIGHT),
strna(p->definition_path),
FORMAT_BYTES(p->copy_blocks_done),
FORMAT_BYTES(p->copy_blocks_size));
if (bps != UINT64_MAX)
(void) draw_progress_barf(
percent,
"%s %s %s %s/%s %s/s",
strna(p->copy_blocks_path),
glyph(GLYPH_ARROW_RIGHT),
strna(p->definition_path),
FORMAT_BYTES(p->copy_blocks_done),
FORMAT_BYTES(p->copy_blocks_size),
FORMAT_BYTES(bps));
else
(void) draw_progress_barf(
percent,
"%s %s %s %s/%s",
strna(p->copy_blocks_path),
glyph(GLYPH_ARROW_RIGHT),
strna(p->definition_path),
FORMAT_BYTES(p->copy_blocks_done),
FORMAT_BYTES(p->copy_blocks_size));
p->last_percent = percent;