aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2011-10-20 16:59:47 -0700
committerH. Peter Anvin <hpa@zytor.com>2011-10-20 16:59:47 -0700
commite8104edd8468c409732e740c0eb5284805422314 (patch)
treec2b88ee46a96225999d39763152e20afc5785195
parent580bd93b8c6bdc95311f27f1dbf4e0b3f92ba22d (diff)
downloadkup-e8104edd8468c409732e740c0eb5284805422314.tar.gz
kup-e8104edd8468c409732e740c0eb5284805422314.tar.xz
kup-e8104edd8468c409732e740c0eb5284805422314.zip
kup-server: when doing large bulk transfers, show status on stderr
When doing large (> 2 s) bulk data transfers, show a status bar on stderr. Suggested-by: Greg KH <greg@kroah.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rwxr-xr-xkup-server17
1 files changed, 17 insertions, 0 deletions
diff --git a/kup-server b/kup-server
index b47bd96..ca3bfbd 100755
--- a/kup-server
+++ b/kup-server
@@ -362,6 +362,11 @@ sub get_blob($$@)
close($oldstdout);
}
+ # We don't show a progress bar if the transfer is very short or
+ # quick, like with typical signatures.
+ my $prog_time = time() + 2;
+ my $prog_perc = -1;
+
my $left = $len;
while ($left) {
my $blk = $left < $bufsiz ? $left : $bufsiz;
@@ -381,11 +386,23 @@ sub get_blob($$@)
}
$left -= $blk;
+
+ my $now = time();
+ my $perc = int((($len-$left)*100)/$len);
+ if ($left == 0 ?
+ ($prog_perc >= 0) : # Show 100% iff we already showed a progress bar
+ ($now > $prog_time && $perc != $proc_perc)) {
+ printf STDERR "%10u [%-50s] %3u%%\r", $len, '=' x ($perc >> 1), $perc;
+ $prog_perc = $perc;
+ $proc_time = $now;
+ }
}
close($outfd)
or fatal("Write error during $cmd");
+ print STDERR "\n" if ($prog_perc >= 0);
+
syslog(LOG_DEBUG, "%u bytes read, %u bytes written", $len, -s $output);
return $len;
}