mirror of
https://github.com/systemd/systemd.git
synced 2025-01-19 14:04:03 +03:00
import: Draw progress bars
Currently every progress update results in a new progress message which is extremely verbose. Instead, let's use the progress bar infra to draw a proper progress bar similar to what we do in systemd-repart now.
This commit is contained in:
parent
a586f57eb2
commit
f0dbe87542
@ -9,9 +9,11 @@
|
||||
#include "copy.h"
|
||||
#include "export-raw.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "import-common.h"
|
||||
#include "missing_fcntl.h"
|
||||
#include "pretty-print.h"
|
||||
#include "ratelimit.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
@ -106,6 +108,7 @@ int raw_export_new(
|
||||
}
|
||||
|
||||
static void raw_export_report_progress(RawExport *e) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
unsigned percent;
|
||||
assert(e);
|
||||
|
||||
@ -121,7 +124,14 @@ static void raw_export_report_progress(RawExport *e) {
|
||||
return;
|
||||
|
||||
sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
|
||||
log_info("Exported %u%%.", percent);
|
||||
|
||||
if (asprintf(&s, "%s %s/%s",
|
||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
||||
FORMAT_BYTES(e->written_uncompressed),
|
||||
FORMAT_BYTES(e->st.st_size)) < 0)
|
||||
return;
|
||||
|
||||
draw_progress_bar(s, percent);
|
||||
|
||||
e->last_percent = percent;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "export-tar.h"
|
||||
#include "fd-util.h"
|
||||
#include "import-common.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "ratelimit.h"
|
||||
#include "string-util.h"
|
||||
@ -113,6 +114,7 @@ int tar_export_new(
|
||||
}
|
||||
|
||||
static void tar_export_report_progress(TarExport *e) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
unsigned percent;
|
||||
assert(e);
|
||||
|
||||
@ -132,7 +134,14 @@ static void tar_export_report_progress(TarExport *e) {
|
||||
return;
|
||||
|
||||
sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
|
||||
log_info("Exported %u%%.", percent);
|
||||
|
||||
if (asprintf(&s, "%s %s/%s",
|
||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
||||
FORMAT_BYTES(e->written_uncompressed),
|
||||
FORMAT_BYTES(e->quota_referenced)) < 0)
|
||||
return;
|
||||
|
||||
draw_progress_bar(s, percent);
|
||||
|
||||
e->last_percent = percent;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "machine-pool.h"
|
||||
#include "mkdir-label.h"
|
||||
#include "path-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "qcow2-util.h"
|
||||
#include "ratelimit.h"
|
||||
#include "rm-rf.h"
|
||||
@ -130,6 +131,7 @@ int raw_import_new(
|
||||
}
|
||||
|
||||
static void raw_import_report_progress(RawImport *i) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
unsigned percent;
|
||||
assert(i);
|
||||
|
||||
@ -149,7 +151,14 @@ static void raw_import_report_progress(RawImport *i) {
|
||||
return;
|
||||
|
||||
sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
|
||||
log_info("Imported %u%%.", percent);
|
||||
|
||||
if (asprintf(&s, "%s %s/%s",
|
||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
||||
FORMAT_BYTES(i->written_compressed),
|
||||
FORMAT_BYTES(i->input_stat.st_size)) < 0)
|
||||
return;
|
||||
|
||||
draw_progress_bar(s, percent);
|
||||
|
||||
i->last_percent = percent;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "machine-pool.h"
|
||||
#include "mkdir-label.h"
|
||||
#include "path-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "process-util.h"
|
||||
#include "qcow2-util.h"
|
||||
#include "ratelimit.h"
|
||||
@ -131,6 +132,7 @@ int tar_import_new(
|
||||
}
|
||||
|
||||
static void tar_import_report_progress(TarImport *i) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
unsigned percent;
|
||||
assert(i);
|
||||
|
||||
@ -150,7 +152,14 @@ static void tar_import_report_progress(TarImport *i) {
|
||||
return;
|
||||
|
||||
sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent);
|
||||
log_info("Imported %u%%.", percent);
|
||||
|
||||
if (asprintf(&s, "%s %s/%s",
|
||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
||||
FORMAT_BYTES(i->written_compressed),
|
||||
FORMAT_BYTES(i->input_stat.st_size)) < 0)
|
||||
return;
|
||||
|
||||
draw_progress_bar(s, percent);
|
||||
|
||||
i->last_percent = percent;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user