mirror of
https://github.com/sheumann/hush.git
synced 2025-01-11 08:29:54 +00:00
wget: make -c _not_ truncate the file
function old new delta retrieve_file_data 396 436 +40 reset_beg_range_to_zero 52 45 -7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
c5b01016e6
commit
6144124aac
@ -352,10 +352,11 @@ static char *gethdr(FILE *fp)
|
|||||||
|
|
||||||
static void reset_beg_range_to_zero(void)
|
static void reset_beg_range_to_zero(void)
|
||||||
{
|
{
|
||||||
//bb_error_msg("restart failed");
|
bb_error_msg("restart failed");
|
||||||
G.beg_range = 0;
|
G.beg_range = 0;
|
||||||
xlseek(G.output_fd, 0, SEEK_SET);
|
xlseek(G.output_fd, 0, SEEK_SET);
|
||||||
ftruncate(G.output_fd, 0);
|
/* Done at the end instead: */
|
||||||
|
/* ftruncate(G.output_fd, 0); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa)
|
static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa)
|
||||||
@ -554,6 +555,17 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
|
|||||||
G.got_clen = 1;
|
G.got_clen = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If -c failed, we restart from the beginning,
|
||||||
|
* 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
|
||||||
|
* failed to restart *without* losing the almost complete file.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
off_t pos = lseek(G.output_fd, 0, SEEK_CUR);
|
||||||
|
if (pos != (off_t)-1)
|
||||||
|
ftruncate(G.output_fd, pos);
|
||||||
|
}
|
||||||
|
|
||||||
/* Draw full bar and free its resources */
|
/* Draw full bar and free its resources */
|
||||||
G.chunked = 0; /* makes it show 100% even for chunked download */
|
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 */
|
G.got_clen = 1; /* makes it show 100% even for download of (formerly) unknown size */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user