summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Gonzalez <rymg19@gmail.com>2020-10-05 11:53:27 -0500
committerAlexander Larsson <alexander.larsson@gmail.com>2020-10-08 09:17:28 +0200
commit9959fd80e9520ce3a6e19feab2fda19a9171b501 (patch)
tree5d3a60dac1f7671652d87103214d5d7d4a3fcf35
parent036aba8cb8ebbbd0854c7e856ec29c3403809006 (diff)
downloadflatpak-9959fd80e9520ce3a6e19feab2fda19a9171b501.tar.gz
repair: Add basic and "fancy" verify progress
This change makes repair print the current ref number being verified and the total number, that way the user can observe the repair progress. In addition, if fancy output is not disabled, the progress will be cleanly printed on a single line. On a dry run, this also will still print the delete messages without actually performing the operations, to show what actions would be taken on a non-dry-run.
-rw-r--r--app/flatpak-builtins-repair.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/app/flatpak-builtins-repair.c b/app/flatpak-builtins-repair.c
index 364998e4..f51e0662 100644
--- a/app/flatpak-builtins-repair.c
+++ b/app/flatpak-builtins-repair.c
@@ -350,6 +350,7 @@ flatpak_builtin_repair (int argc, char **argv, GCancellable *cancellable, GError
if (!ostree_repo_list_refs (repo, NULL, &all_refs, cancellable, error))
return FALSE;
+ i = 0;
GLNX_HASH_TABLE_FOREACH_KV (all_refs, const char *, refspec, const char *, checksum)
{
g_autofree char *remote = NULL;
@@ -379,11 +380,23 @@ flatpak_builtin_repair (int argc, char **argv, GCancellable *cancellable, GError
}
}
- g_print (_("Verifying %s…\n"), refspec);
+ /* When printing progress, we have to print a newline character at the end, otherwise errors printing in
+ sections of the code that we don't control won't have a leading newline. Therefore, the status line will
+ always print a trailing newline, and here we just go up a line back onto the previous progress line.
+
+ This does also mean that other areas of this code section that print errors will need to print a trailing
+ newline as well, otherwise the output will overwrite any errors. */
+ if (flatpak_fancy_output ())
+ g_print ("\033[A\r\033[K");
+
+ g_print (_("[%d/%d] Verifying %s…\n"), ++i, g_hash_table_size (all_refs), refspec);
status = fsck_commit (repo, checksum, object_status_cache);
- if (status != FSCK_STATUS_OK && !opt_dry_run)
+ if (status != FSCK_STATUS_OK)
{
+ if (opt_dry_run)
+ g_printerr (_("Dry run: "));
+
switch (status)
{
case FSCK_STATUS_HAS_MISSING_OBJECTS:
@@ -398,10 +411,19 @@ flatpak_builtin_repair (int argc, char **argv, GCancellable *cancellable, GError
g_printerr (_("Deleting ref %s due to %d\n"), refspec, status);
break;
}
- (void) ostree_repo_set_ref_immediate (repo, remote, ref_name, NULL, cancellable, NULL);
+
+ if (!opt_dry_run)
+ (void) ostree_repo_set_ref_immediate (repo, remote, ref_name, NULL, cancellable, NULL);
+
+ /* If using fancy output, print another trailing newline, so the next progress line won't overwrite
+ these errors. */
+ if (flatpak_fancy_output () && i < g_hash_table_size (all_refs))
+ g_print ("\n");
}
}
+ g_print (_("Checking remotes...\n"));
+
GLNX_HASH_TABLE_FOREACH_KV (all_refs, const char *, refspec, const char *, checksum)
{
g_autofree char *remote = NULL;