wget: fix progress bar and message placement on unexpected EOF (and retry)
Correct behavior: "wget: connection closed..." on new line: $ wget http://127.0.0.1/50g -O/dev/null Connecting to 127.0.0.1 (127.0.0.1:80) saving to '/dev/null' null 8% |** | 4531M 0:00:30 ETA wget: connection closed at byte 4751158460 Connecting to 127.0.0.1 (127.0.0.1:80) saving to '/dev/null' null 10% |***_ function old new delta progress_meter 182 195 +13 retrieve_file_data 705 697 -8 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 13/-8) Total: 5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
1 parent
218f328625
commit
bf9ebfe168
1 file changed
+5
-2
+5
-2
@@ -333,6 +333,9 @@ static void progress_meter(int flag)
|
||||
if (flag == PROGRESS_START)
|
||||
bb_progress_init(&G.pmt, G.curfile);
|
||||
|
||||
if (flag == PROGRESS_END)
|
||||
G.pmt.last_update_sec = 0; /* force update (and correct "notty") */
|
||||
|
||||
notty = bb_progress_update(&G.pmt,
|
||||
G.beg_range,
|
||||
G.transferred,
|
||||
@@ -1010,11 +1013,11 @@ static int NOINLINE retrieve_file_data(FILE *dfp)
|
||||
* fread does not distinguish between EOF and error.
|
||||
*/
|
||||
if (errno != EAGAIN) {
|
||||
progress_meter(PROGRESS_END);
|
||||
if (ferror(dfp)) {
|
||||
progress_meter(PROGRESS_END);
|
||||
bb_simple_perror_msg(bb_msg_read_error);
|
||||
G.content_len = 1; /* treat end as error, not EOF */
|
||||
}
|
||||
G.content_len = 1; /* treat end as error, not EOF */
|
||||
goto EOF_err; /* EOF / error */
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user