From e189308068abbb9de44dae32a984cdf77a749d97 Mon Sep 17 00:00:00 2001 From: wollman Date: Mon, 10 Feb 1997 18:49:42 +0000 Subject: [PATCH] Fix PR#2700: report correct transmission speed, and restart transfers from the restart point, not the end of the file (blush!). Submitted by: John-Mark Gurney --- usr.bin/fetch/ftp.c | 4 ++-- usr.bin/fetch/main.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.bin/fetch/ftp.c b/usr.bin/fetch/ftp.c index 0960b8158419..1b8e0fe00dc8 100644 --- a/usr.bin/fetch/ftp.c +++ b/usr.bin/fetch/ftp.c @@ -26,7 +26,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ftp.c,v 1.1 1997/01/30 21:43:40 wollman Exp $ + * $Id: ftp.c,v 1.2 1997/02/05 19:59:12 wollman Exp $ */ #include @@ -327,7 +327,7 @@ ftp_retrieve(struct fetch_state *fs) } if (fs->fs_restart) { if (stab.st_size != 0 && stab.st_size < size) - seekloc = wehave = size; + seekloc = wehave = stab.st_size; } } diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c index 1b899a2b52d0..2aa7b9eb259c 100644 --- a/usr.bin/fetch/main.c +++ b/usr.bin/fetch/main.c @@ -73,7 +73,7 @@ main(int argc, char *const *argv) fs.fs_verbose = 1; change_to_dir = file_to_get = hostname = 0; - while ((c = getopt(argc, argv, "ac:D:f:h:HilLmMnNo:pPqrT:vV:")) != -1) { + while ((c = getopt(argc, argv, "ac:D:f:h:HilLmMnNo:pPqRrT:vV:")) != -1) { switch (c) { case 'D': case 'H': case 'I': case 'N': case 'L': case 'V': break; /* ncftp compatibility */ @@ -286,6 +286,7 @@ void display(struct fetch_state *fs, off_t size, ssize_t n) { static off_t bytes; + static off_t bytestart; static int pr, init = 0; static struct timeval t0, t_start; static char *s; @@ -309,7 +310,7 @@ display(struct fetch_state *fs, off_t size, ssize_t n) sprintf (s, "Receiving %s", fs->fs_outputfile); printf ("%s", s); fflush (stdout); - bytes = n; + bytestart = bytes = n; return; } gettimeofday(&t, &tz); @@ -318,6 +319,7 @@ display(struct fetch_state *fs, off_t size, ssize_t n) printf ("\r%s: 100%%", s); else printf ("\r%s: %qd Kbytes", s, (quad_t)bytes/1024); + bytes -= bytestart; d = t.tv_sec + t.tv_usec/1.e6 - t_start.tv_sec - t_start.tv_usec/1.e6; printf ("\n%qd bytes transfered in %.1f seconds", (quad_t)bytes, d); d = bytes/d;