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 <jmg@nike.efn.org>
This commit is contained in:
parent
7c4a46a3a0
commit
e189308068
@ -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 <sys/types.h>
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user