summaryrefslogtreecommitdiff
path: root/progressmeter.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2019-01-24 16:52:17 +0000
committerDarren Tucker <dtucker@dtucker.net>2019-01-25 06:32:14 +1100
commitbdc6c63c80b55bcbaa66b5fde31c1cb1d09a41eb (patch)
treea45a5111a1f6616dd5a79544d6f0e59ca64dff30 /progressmeter.c
parent258e6ca003e47f944688ad8b8de087b58a7d966c (diff)
upstream: Have progressmeter force an update at the beginning and
end of each transfer. Fixes the problem recently introduces where very quick transfers do not display the progressmeter at all. Spotted by naddy@ OpenBSD-Commit-ID: 68dc46c259e8fdd4f5db3ec2a130f8e4590a7a9a
Diffstat (limited to 'progressmeter.c')
-rw-r--r--progressmeter.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/progressmeter.c b/progressmeter.c
index add462dde..e385c1254 100644
--- a/progressmeter.c
+++ b/progressmeter.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: progressmeter.c,v 1.46 2019/01/23 08:01:46 dtucker Exp $ */ 1/* $OpenBSD: progressmeter.c,v 1.47 2019/01/24 16:52:17 dtucker Exp $ */
2/* 2/*
3 * Copyright (c) 2003 Nils Nordman. All rights reserved. 3 * Copyright (c) 2003 Nils Nordman. All rights reserved.
4 * 4 *
@@ -59,9 +59,6 @@ static void format_rate(char *, int, off_t);
59static void sig_winch(int); 59static void sig_winch(int);
60static void setscreensize(void); 60static void setscreensize(void);
61 61
62/* updates the progressmeter to reflect the current state of the transfer */
63void refresh_progress_meter(void);
64
65/* signal handler for updating the progress meter */ 62/* signal handler for updating the progress meter */
66static void sig_alarm(int); 63static void sig_alarm(int);
67 64
@@ -120,7 +117,7 @@ format_size(char *buf, int size, off_t bytes)
120} 117}
121 118
122void 119void
123refresh_progress_meter(void) 120refresh_progress_meter(int force_update)
124{ 121{
125 char buf[MAX_WINSIZE + 1]; 122 char buf[MAX_WINSIZE + 1];
126 off_t transferred; 123 off_t transferred;
@@ -131,7 +128,7 @@ refresh_progress_meter(void)
131 int hours, minutes, seconds; 128 int hours, minutes, seconds;
132 int file_len; 129 int file_len;
133 130
134 if ((!alarm_fired && !win_resized) || !can_output()) 131 if ((!force_update && !alarm_fired && !win_resized) || !can_output())
135 return; 132 return;
136 alarm_fired = 0; 133 alarm_fired = 0;
137 134
@@ -254,7 +251,7 @@ start_progress_meter(const char *f, off_t filesize, off_t *ctr)
254 bytes_per_second = 0; 251 bytes_per_second = 0;
255 252
256 setscreensize(); 253 setscreensize();
257 refresh_progress_meter(); 254 refresh_progress_meter(1);
258 255
259 signal(SIGALRM, sig_alarm); 256 signal(SIGALRM, sig_alarm);
260 signal(SIGWINCH, sig_winch); 257 signal(SIGWINCH, sig_winch);
@@ -271,7 +268,7 @@ stop_progress_meter(void)
271 268
272 /* Ensure we complete the progress */ 269 /* Ensure we complete the progress */
273 if (cur_pos != end_pos) 270 if (cur_pos != end_pos)
274 refresh_progress_meter(); 271 refresh_progress_meter(1);
275 272
276 atomicio(vwrite, STDOUT_FILENO, "\n", 1); 273 atomicio(vwrite, STDOUT_FILENO, "\n", 1);
277} 274}