wget: fix ndelay_on call; progress bar: small shrink
function old new delta bb_progress_update 682 670 -12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
64f2ba276c
commit
da0df47f24
@ -76,7 +76,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
|
|||||||
elapsed = monotonic_sec();
|
elapsed = monotonic_sec();
|
||||||
since_last_update = elapsed - p->lastupdate_sec;
|
since_last_update = elapsed - p->lastupdate_sec;
|
||||||
/* Do not update on every call
|
/* Do not update on every call
|
||||||
* (might be: on every network read!) */
|
* (we can be called on every network read!) */
|
||||||
if (since_last_update == 0 && !totalsize)
|
if (since_last_update == 0 && !totalsize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
|
|||||||
ratio = 100;
|
ratio = 100;
|
||||||
if (beg_and_transferred < totalsize) {
|
if (beg_and_transferred < totalsize) {
|
||||||
/* Do not update on every call
|
/* Do not update on every call
|
||||||
* (might be: on every network read!) */
|
* (we can be called on every network read!) */
|
||||||
if (since_last_update == 0)
|
if (since_last_update == 0)
|
||||||
return;
|
return;
|
||||||
/* long long helps to have it working even if !LFS */
|
/* long long helps to have it working even if !LFS */
|
||||||
@ -118,14 +118,14 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
|
|||||||
barlength = get_tty2_width() - 49;
|
barlength = get_tty2_width() - 49;
|
||||||
if (barlength > 0) {
|
if (barlength > 0) {
|
||||||
/* god bless gcc for variable arrays :) */
|
/* god bless gcc for variable arrays :) */
|
||||||
i = barlength * ratio / 100;
|
char buf[barlength + 1];
|
||||||
{
|
unsigned stars = (unsigned)barlength * ratio / (unsigned)100;
|
||||||
char buf[i+1];
|
memset(buf, ' ', barlength);
|
||||||
memset(buf, '*', i);
|
buf[barlength] = '\0';
|
||||||
buf[i] = '\0';
|
memset(buf, '*', stars);
|
||||||
fprintf(stderr, "|%s%*s|", buf, barlength - i, "");
|
fprintf(stderr, "|%s|", buf);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (beg_and_transferred >= 100000) {
|
while (beg_and_transferred >= 100000) {
|
||||||
i++;
|
i++;
|
||||||
@ -155,10 +155,10 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p,
|
|||||||
fprintf(stderr, "--:--:-- ETA");
|
fprintf(stderr, "--:--:-- ETA");
|
||||||
} else {
|
} else {
|
||||||
/* to_download / (transferred/elapsed) - elapsed: */
|
/* to_download / (transferred/elapsed) - elapsed: */
|
||||||
int eta = (int) ((unsigned long long)to_download*elapsed/transferred - elapsed);
|
|
||||||
/* (long long helps to have working ETA even if !LFS) */
|
/* (long long helps to have working ETA even if !LFS) */
|
||||||
i = eta % 3600;
|
unsigned eta = (unsigned long long)to_download*elapsed/(uoff_t)transferred - elapsed;
|
||||||
fprintf(stderr, "%02d:%02d:%02d ETA", eta / 3600, i / 60, i % 60);
|
unsigned secs = eta % 3600;
|
||||||
|
fprintf(stderr, "%02u:%02u:%02u ETA", eta / 3600, secs / 60, secs % 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,7 +455,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp, int output_fd)
|
|||||||
|
|
||||||
polldata.fd = fileno(dfp);
|
polldata.fd = fileno(dfp);
|
||||||
polldata.events = POLLIN | POLLPRI;
|
polldata.events = POLLIN | POLLPRI;
|
||||||
ndelay(polldata.fd);
|
ndelay_on(polldata.fd);
|
||||||
#endif
|
#endif
|
||||||
progress_meter(PROGRESS_START);
|
progress_meter(PROGRESS_START);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user