Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4a00148

Browse files
committed
Properly clear the verbose output of pg_basebackup
Don't leave partial filename information on the last status or dangling characters if the previous filename was longer than the current one.
1 parent 56bb7f2 commit 4a00148

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,24 @@ progress_report(int tablespacenum, char *fn)
207207
percent = 100;
208208

209209
if (verbose)
210-
fprintf(stderr,
211-
INT64_FORMAT "/" INT64_FORMAT " kB (%i%%) %i/%i tablespaces (%-30s)\r",
212-
totaldone / 1024, totalsize,
213-
percent,
214-
tablespacenum, tablespacecount, fn);
210+
{
211+
if (!fn)
212+
213+
/*
214+
* No filename given, so clear the status line (used for last
215+
* call)
216+
*/
217+
fprintf(stderr,
218+
INT64_FORMAT "/" INT64_FORMAT " kB (100%%) %i/%i tablespaces %35s\r",
219+
totaldone / 1024, totalsize,
220+
tablespacenum, tablespacecount, "");
221+
else
222+
fprintf(stderr,
223+
INT64_FORMAT "/" INT64_FORMAT " kB (%i%%) %i/%i tablespaces (%-30.30s)\r",
224+
totaldone / 1024, totalsize,
225+
percent,
226+
tablespacenum, tablespacecount, fn);
227+
}
215228
else
216229
fprintf(stderr, INT64_FORMAT "/" INT64_FORMAT " kB (%i%%) %i/%i tablespaces\r",
217230
totaldone / 1024, totalsize,
@@ -871,7 +884,7 @@ BaseBackup()
871884

872885
if (showprogress)
873886
{
874-
progress_report(PQntuples(res), "");
887+
progress_report(PQntuples(res), NULL);
875888
fprintf(stderr, "\n"); /* Need to move to next line */
876889
}
877890
PQclear(res);

0 commit comments

Comments
 (0)