summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/progressmeter.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2013-09-19 00:24:53 +0000
committerDamien Miller <djm@cvs.openbsd.org>2013-09-19 00:24:53 +0000
commit49062d79e705dea418edb651f470763d8a320123 (patch)
treecc7bfeb11157b5d3a1003bf4bc102757f492b573 /usr.bin/ssh/progressmeter.c
parent9c5030666f2b928afbf175cbc7ca63d804fa1e7b (diff)
store the initial file offset so the progress meter doesn't freak out
when resuming sftp transfers. bz#2137; patch from Iain Morgan; ok dtucker@
Diffstat (limited to 'usr.bin/ssh/progressmeter.c')
-rw-r--r--usr.bin/ssh/progressmeter.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/ssh/progressmeter.c b/usr.bin/ssh/progressmeter.c
index 1840b206124..5c4ae992d57 100644
--- a/usr.bin/ssh/progressmeter.c
+++ b/usr.bin/ssh/progressmeter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: progressmeter.c,v 1.39 2013/06/02 13:33:05 dtucker Exp $ */
+/* $OpenBSD: progressmeter.c,v 1.40 2013/09/19 00:24:52 djm Exp $ */
/*
* Copyright (c) 2003 Nils Nordman. All rights reserved.
*
@@ -64,6 +64,7 @@ static void update_progress_meter(int);
static time_t start; /* start progress */
static time_t last_update; /* last progress update */
static char *file; /* name of the file being transferred */
+static off_t start_pos; /* initial position of transfer */
static off_t end_pos; /* ending position of transfer */
static off_t cur_pos; /* transfer position as of last refresh */
static volatile off_t *counter; /* progress counter */
@@ -127,7 +128,7 @@ refresh_progress_meter(void)
int i, len;
int file_len;
- transferred = *counter - cur_pos;
+ transferred = *counter - (cur_pos ? cur_pos : start_pos);
cur_pos = *counter;
now = monotime();
bytes_left = end_pos - cur_pos;
@@ -137,7 +138,7 @@ refresh_progress_meter(void)
else {
elapsed = now - start;
/* Calculate true total speed when done */
- transferred = end_pos;
+ transferred = end_pos - start_pos;
bytes_per_second = 0;
}
@@ -249,6 +250,7 @@ start_progress_meter(char *f, off_t filesize, off_t *ctr)
{
start = last_update = monotime();
file = f;
+ start_pos = *ctr;
end_pos = filesize;
cur_pos = 0;
counter = ctr;