diff options
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/export-raw.c | 16 | ||||
-rw-r--r-- | src/import/export-tar.c | 15 | ||||
-rw-r--r-- | src/import/import-raw.c | 15 | ||||
-rw-r--r-- | src/import/import-tar.c | 15 | ||||
-rw-r--r-- | src/import/importctl.c | 2 |
5 files changed, 58 insertions, 5 deletions
diff --git a/src/import/export-raw.c b/src/import/export-raw.c index f425396261..5e34fd372e 100644 --- a/src/import/export-raw.c +++ b/src/import/export-raw.c @@ -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" @@ -121,7 +123,16 @@ static void raw_export_report_progress(RawExport *e) { return; sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); - log_info("Exported %u%%.", percent); + + if (isatty_safe(STDERR_FILENO)) + (void) draw_progress_barf( + percent, + "%s %s/%s", + special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), + FORMAT_BYTES(e->written_uncompressed), + FORMAT_BYTES(e->st.st_size)); + else + log_info("Exported %u%%.", percent); e->last_percent = percent; } @@ -215,6 +226,9 @@ static int raw_export_process(RawExport *e) { finish: if (r >= 0) { + if (isatty_safe(STDERR_FILENO)) + clear_progress_bar(/* prefix= */ NULL); + (void) copy_times(e->input_fd, e->output_fd, COPY_CRTIME); (void) copy_xattr(e->input_fd, NULL, e->output_fd, NULL, 0); } diff --git a/src/import/export-tar.c b/src/import/export-tar.c index 9e92badfef..e025efe411 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -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" @@ -132,7 +133,16 @@ static void tar_export_report_progress(TarExport *e) { return; sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); - log_info("Exported %u%%.", percent); + + if (isatty_safe(STDERR_FILENO)) + (void) draw_progress_barf( + percent, + "%s %s/%s", + special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), + FORMAT_BYTES(e->written_uncompressed), + FORMAT_BYTES(e->quota_referenced)); + else + log_info("Exported %u%%.", percent); e->last_percent = percent; } @@ -229,6 +239,9 @@ static int tar_export_process(TarExport *e) { return 0; finish: + if (r >= 0 && isatty_safe(STDERR_FILENO)) + clear_progress_bar(/* prefix= */ NULL); + if (e->on_finished) e->on_finished(e, r, e->userdata); else diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 78775b96d6..602d1f1ac3 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -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" @@ -149,7 +150,16 @@ static void raw_import_report_progress(RawImport *i) { return; sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); - log_info("Imported %u%%.", percent); + + if (isatty_safe(STDERR_FILENO)) + (void) draw_progress_barf( + percent, + "%s %s/%s", + special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), + FORMAT_BYTES(i->written_compressed), + FORMAT_BYTES(i->input_stat.st_size)); + else + log_info("Imported %u%%.", percent); i->last_percent = percent; } @@ -459,6 +469,9 @@ static int raw_import_process(RawImport *i) { return 0; complete: + if (isatty_safe(STDERR_FILENO)) + clear_progress_bar(/* prefix= */ NULL); + r = raw_import_finish(i); finish: diff --git a/src/import/import-tar.c b/src/import/import-tar.c index 976c918246..e82159cb52 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -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" @@ -150,7 +151,16 @@ static void tar_import_report_progress(TarImport *i) { return; sd_notifyf(false, "X_IMPORT_PROGRESS=%u%%", percent); - log_info("Imported %u%%.", percent); + + if (isatty_safe(STDERR_FILENO)) + (void) draw_progress_barf( + percent, + "%s %s/%s", + special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), + FORMAT_BYTES(i->written_compressed), + FORMAT_BYTES(i->input_stat.st_size)); + else + log_info("Imported %u%%.", percent); i->last_percent = percent; } @@ -322,6 +332,9 @@ static int tar_import_process(TarImport *i) { return 0; finish: + if (r >= 0 && isatty_safe(STDERR_FILENO)) + clear_progress_bar(/* prefix= */ NULL); + if (i->on_finished) i->on_finished(i, r, i->userdata); else diff --git a/src/import/importctl.c b/src/import/importctl.c index 0ddfa988a6..1ddba76b09 100644 --- a/src/import/importctl.c +++ b/src/import/importctl.c @@ -936,7 +936,7 @@ static int list_images(int argc, char *argv[], void *userdata) { if (r < 0) return table_log_add_error(r); - if (FLAGS_SET(arg_json_format_flags, SD_JSON_FORMAT_OFF)) + if (!sd_json_format_enabled(arg_json_format_flags)) r = table_add_many( t, TABLE_STRING, read_only ? "ro" : "rw", |