wget: detect when the length of received file is less than advertised
function old new delta retrieve_file_data 579 596 +17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4906faafab
commit
9b313ddcd8
@ -248,7 +248,7 @@ struct globals {
|
|||||||
* With 512 byte buffer, it was measured to be
|
* With 512 byte buffer, it was measured to be
|
||||||
* an order of magnitude slower than with big one.
|
* an order of magnitude slower than with big one.
|
||||||
*/
|
*/
|
||||||
char wget_buf[CONFIG_FEATURE_COPYBUF_KB*1024] ALIGNED(sizeof(long));
|
char wget_buf[CONFIG_FEATURE_COPYBUF_KB*1024] ALIGNED(16);
|
||||||
} FIX_ALIASING;
|
} FIX_ALIASING;
|
||||||
#define G (*ptr_to_globals)
|
#define G (*ptr_to_globals)
|
||||||
#define INIT_G() do { \
|
#define INIT_G() do { \
|
||||||
@ -388,9 +388,6 @@ static void set_alarm(void)
|
|||||||
* is_ip_address() attempts to verify whether or not a string
|
* is_ip_address() attempts to verify whether or not a string
|
||||||
* contains an IPv4 or IPv6 address (vs. an FQDN). The result
|
* contains an IPv4 or IPv6 address (vs. an FQDN). The result
|
||||||
* of inet_pton() can be used to determine this.
|
* of inet_pton() can be used to determine this.
|
||||||
*
|
|
||||||
* TODO add proper error checking when inet_pton() returns -1
|
|
||||||
* (some form of system error has occurred, and errno is set)
|
|
||||||
*/
|
*/
|
||||||
static int is_ip_address(const char *string)
|
static int is_ip_address(const char *string)
|
||||||
{
|
{
|
||||||
@ -1012,6 +1009,15 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Draw full bar and free its resources */
|
||||||
|
G.chunked = 0; /* makes it show 100% even for chunked download */
|
||||||
|
G.got_clen = 1; /* makes it show 100% even for download of (formerly) unknown size */
|
||||||
|
progress_meter(PROGRESS_END);
|
||||||
|
if (G.content_len != 0) {
|
||||||
|
bb_perror_msg_and_die("connection closed prematurely");
|
||||||
|
/* GNU wget says "DATE TIME (NN MB/s) - Connection closed at byte NNN. Retrying." */
|
||||||
|
}
|
||||||
|
|
||||||
/* If -c failed, we restart from the beginning,
|
/* If -c failed, we restart from the beginning,
|
||||||
* but we do not truncate file then, we do it only now, at the end.
|
* but we do not truncate file then, we do it only now, at the end.
|
||||||
* This lets user to ^C if his 99% complete 10 GB file download
|
* This lets user to ^C if his 99% complete 10 GB file download
|
||||||
@ -1023,10 +1029,6 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
|
|||||||
ftruncate(G.output_fd, pos);
|
ftruncate(G.output_fd, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw full bar and free its resources */
|
|
||||||
G.chunked = 0; /* makes it show 100% even for chunked download */
|
|
||||||
G.got_clen = 1; /* makes it show 100% even for download of (formerly) unknown size */
|
|
||||||
progress_meter(PROGRESS_END);
|
|
||||||
if (!(option_mask32 & WGET_OPT_QUIET)) {
|
if (!(option_mask32 & WGET_OPT_QUIET)) {
|
||||||
if (G.output_fd == 1)
|
if (G.output_fd == 1)
|
||||||
fprintf(stderr, "written to stdout\n");
|
fprintf(stderr, "written to stdout\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user