• R/O
  • SSH
  • HTTPS

svardos: Commit


Commit MetaInfo

Revision332 (tree)
Time2021-05-14 18:14:21
Authormateuszviste

Log Message

prints out download speed during transfer + avoids libc console buffering

Change Summary

Incremental Difference

--- pkgnet/pkgnet.c (revision 331)
+++ pkgnet/pkgnet.c (revision 332)
@@ -34,7 +34,7 @@
3434
3535 #include "net.h"
3636
37-#define PVER "20210513"
37+#define PVER "20210514"
3838 #define PDATE "2021"
3939
4040 #define HOSTADDR "svardos.osdn.io"
@@ -117,7 +117,7 @@
117117 time_t lastactivity, lastprogressoutput = 0;
118118 int headersdone = 0;
119119 int httpcode = -1;
120- long flen = 0;
120+ long flen = 0, lastflen = 0;
121121 FILE *fd = NULL;
122122
123123 sock = net_connect(ipaddr, 80);
@@ -208,7 +208,9 @@
208208 /* update progress once a sec */
209209 if (lastprogressoutput != lastactivity) {
210210 lastprogressoutput = lastactivity;
211- printf("%ld KiB\r", flen >> 10);
211+ printf("%ld KiB (%ld KiB/s)\r", flen >> 10, (flen >> 10) - (lastflen >> 10));
212+ lastflen = flen;
213+ fflush(stdout); /* avoid console buffering */
212214 }
213215 /* update the bsd sum */
214216 for (i = 0; i < byteread; i++) {
Show on old repository browser