Re: [Bug-wget] [PATCH v2] Make wget capable of starting download from a specified position.

2013-12-21 Thread Darshit Shah
There is a typo in doc/wget.texi:718. s/Serer/Server
Also, please add a line about the new command in the help output in main.c.



On Sun, Dec 22, 2013 at 9:33 AM, Yousong Zhou  wrote:

> This patch adds an option `--start-pos' for specifying starting position
> of a download, both for HTTP and FTP.  When specified, the newly added
> option would override `--continue'.  Apart from that, no existing code
> should be affected.
>
> Signed-off-by: Yousong Zhou 
> ---
> v1 -> v2
>
> It was kindly pointed out by Darshit Shah  that
> server support for resuming download is required, so adding this
> into
> doc/wget.texi.
>
>  doc/ChangeLog |4 
>  doc/wget.texi |   17 +
>  src/ChangeLog |9 +
>  src/ftp.c |2 ++
>  src/http.c|2 ++
>  src/init.c|1 +
>  src/main.c|1 +
>  src/options.h |1 +
>  8 files changed, 37 insertions(+), 0 deletions(-)
>



-- 
Thanking You,
Darshit Shah


[Bug-wget] [PATCH v2] Make wget capable of starting download from a specified position.

2013-12-21 Thread Yousong Zhou
This patch adds an option `--start-pos' for specifying starting position
of a download, both for HTTP and FTP.  When specified, the newly added
option would override `--continue'.  Apart from that, no existing code
should be affected.

Signed-off-by: Yousong Zhou 
---
v1 -> v2

It was kindly pointed out by Darshit Shah  that
server support for resuming download is required, so adding this into
doc/wget.texi.

 doc/ChangeLog |4 
 doc/wget.texi |   17 +
 src/ChangeLog |9 +
 src/ftp.c |2 ++
 src/http.c|2 ++
 src/init.c|1 +
 src/main.c|1 +
 src/options.h |1 +
 8 files changed, 37 insertions(+), 0 deletions(-)
>From 93152cb081f529762a364eea67115f654cd6fda4 Mon Sep 17 00:00:00 2001
From: Yousong Zhou 
Date: Fri, 20 Dec 2013 23:17:43 +0800
Subject: [PATCH v2] Make wget capable of starting download from a specified position.

This patch adds an option `--start-pos' for specifying starting position
of a download, both for HTTP and FTP.  When specified, the newly added
option would override `--continue'.  Apart from that, no existing code
should be affected.

Signed-off-by: Yousong Zhou 
---
v1 -> v2

	It was kindly pointed out by Darshit Shah  that
	server support for resuming download is required, so adding this into
	doc/wget.texi.

 doc/ChangeLog |4 
 doc/wget.texi |   17 +
 src/ChangeLog |9 +
 src/ftp.c |2 ++
 src/http.c|2 ++
 src/init.c|1 +
 src/main.c|1 +
 src/options.h |1 +
 8 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/doc/ChangeLog b/doc/ChangeLog
index 3b05756..df103c8 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-21  Yousong Zhou  
+
+	* wget.texi: Add documentation for --start-pos.
+
 2013-10-06  Tim Ruehsen  
 
 	* wget.texi: add/explain quoting of wildcard patterns
diff --git a/doc/wget.texi b/doc/wget.texi
index 4a1f7f1..9151d28 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -701,6 +701,23 @@ Another instance where you'll get a garbled file if you try to use
 Note that @samp{-c} only works with @sc{ftp} servers and with @sc{http}
 servers that support the @code{Range} header.
 
+@cindex offset
+@cindex continue retrieval
+@cindex incomplete downloads
+@cindex resume download
+@cindex start position
+@item --start-pos=@var{OFFSET}
+Start the download at position @var{OFFSET}.  Offset may be expressed in bytes,
+kilobytes with the `k' suffix, or megabytes with the `m' suffix.
+
+When specified, it would override the behavior of @samp{--continue}.  When
+using this option, you may also want to explicitly specify an output filename
+with @samp{-O FILE} in order to not overwrite an existing partially downloaded
+file.
+
+Serer support for resuming download is needed, otherwise @samp{--start-pos}
+cannot help.  See @samp{-c} for details.
+
 @cindex progress indicator
 @cindex dot style
 @item --progress=@var{type}
diff --git a/src/ChangeLog b/src/ChangeLog
index 42ce3e4..ab8a496 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2013-12-21  Yousong Zhou  
+
+	* options.h: Add option --start-pos to specify start position of
+	  a download.
+	* main.c: Same purpose as above.
+	* init.c: Same purpose as above.
+	* http.c: Utilize opt.start_pos for HTTP download.
+	* ftp.c: Utilize opt.start_pos for FTP retrieval.
+
 2013-11-02  Giuseppe Scrivano  
 
 	* http.c (gethttp): Increase max header value length to 512.
diff --git a/src/ftp.c b/src/ftp.c
index c2522ca..c7ab6ef 100644
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1632,6 +1632,8 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi
   /* Decide whether or not to restart.  */
   if (con->cmd & DO_LIST)
 restval = 0;
+  else if (opt.start_pos)
+restval = opt.start_pos;
   else if (opt.always_rest
   && stat (locf, &st) == 0
   && S_ISREG (st.st_mode))
diff --git a/src/http.c b/src/http.c
index 754b7ec..a354c6b 100644
--- a/src/http.c
+++ b/src/http.c
@@ -3098,6 +3098,8 @@ Spider mode enabled. Check if remote file exists.\n"));
   /* Decide whether or not to restart.  */
   if (force_full_retrieve)
 hstat.restval = hstat.len;
+  else if (opt.start_pos)
+hstat.restval = opt.start_pos;
   else if (opt.always_rest
   && got_name
   && stat (hstat.local_file, &st) == 0
diff --git a/src/init.c b/src/init.c
index 84ae654..7f7a34e 100644
--- a/src/init.c
+++ b/src/init.c
@@ -271,6 +271,7 @@ static const struct {
   { "showalldnsentries", &opt.show_all_dns_entries, cmd_boolean },
   { "spanhosts",&opt.spanhost,  cmd_boolean },
   { "spider",   &opt.spider,cmd_boolean },
+  { "startpos", &opt.start_pos, cmd_bytes },
   { "strictcomments",   &opt.strict_comments,   cmd_boolean },
   { "timeout",  NULL,   cmd_spec_timeout },
   { "timestamping", &opt