Document and fix --backups option

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2013-07-15 09:00:49 +02:00
parent 67958755aa
commit b34c7e0e16
3 changed files with 146 additions and 1 deletions

View File

@ -0,0 +1,60 @@
From 44ba49b31f4ea515f8a6ef2642a34c0fd2024b90 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <gscrivano@gnu.org>
Date: Tue, 9 Jul 2013 00:50:30 +0200
Subject: [PATCH] doc: document --backups
---
doc/wget.texi | 15 ++++++++++++---
src/main.c | 3 +++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/doc/wget.texi b/doc/wget.texi
index 5054382..7a1670e 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -630,6 +630,13 @@ Note that when @samp{-nc} is specified, files with the suffixes
@samp{.html} or @samp{.htm} will be loaded from the local disk and
parsed as if they had been retrieved from the Web.
+@cindex backing up files
+@item --backups=@var{backups}
+Before (over)writing a file, back up an existing file by adding a
+@samp{.1} suffix (@samp{_1} on VMS) to the file name. Such backup
+files are rotated to @samp{.2}, @samp{.3}, and so on, up to
+@var{backups} (and lost beyond that).
+
@cindex continue retrieval
@cindex incomplete downloads
@cindex resume download
@@ -2882,9 +2889,11 @@ enables it).
Enable/disable saving pre-converted files with the suffix
@samp{.orig}---the same as @samp{-K} (which enables it).
-@c @item backups = @var{number}
-@c #### Document me!
-@c
+@item backups = @var{number}
+Use up to @var{number} backups for a file. Backups are rotated by
+adding an incremental counter that starts at @samp{1}. The default is
+@samp{0}.
+
@item base = @var{string}
Consider relative @sc{url}s in input files (specified via the
@samp{input} command or the @samp{--input-file}/@samp{-i} option,
diff --git a/src/main.c b/src/main.c
index c895c4e..8ce0eb3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -714,6 +714,9 @@ Recursive download:\n"),
N_("\
-k, --convert-links make links in downloaded HTML or CSS point to\n\
local files.\n"),
+ N_("\
+ --backups=N before writing file X, rotate up to N backup files.\n"),
+
#ifdef __VMS
N_("\
-K, --backup-converted before converting file X, back up as X_orig.\n"),
--
1.8.3.1

View File

@ -0,0 +1,80 @@
From c52bbad9e4bad1393a9d6ba37e600d388f5ab419 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <gscrivano@gnu.org>
Date: Wed, 10 Jul 2013 20:59:34 +0200
Subject: [PATCH] Make --backups work as documented
---
src/http.c | 6 ------
src/options.h | 2 +-
src/url.c | 3 ++-
src/url.h | 6 ++++++
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/http.c b/src/http.c
index 9f274dc..b0c782b 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1641,12 +1641,6 @@ read_response_body (struct http_stat *hs, int sock, FILE *fp, wgint contlen,
} while (0)
#endif /* def __VMS [else] */
-/* The flags that allow clobbering the file (opening with "wb").
- Defined here to avoid repetition later. #### This will require
- rework. */
-#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
- || opt.dirstruct || opt.output_document)
-
/* Retrieve a document through HTTP protocol. It recognizes status
code, and correctly handles redirections. It closes the network
socket. If it receives an error from the functions below it, it
diff --git a/src/options.h b/src/options.h
index ed38617..0a10c9b 100644
--- a/src/options.h
+++ b/src/options.h
@@ -166,7 +166,7 @@ struct options
bool timestamping; /* Whether to use time-stamping. */
bool backup_converted; /* Do we save pre-converted files as *.orig? */
- bool backups; /* Are numeric backups made? */
+ int backups; /* Are numeric backups made? */
char *useragent; /* User-Agent string, which can be set
to something other than Wget. */
diff --git a/src/url.c b/src/url.c
index 5e2b9a3..bf9d697 100644
--- a/src/url.c
+++ b/src/url.c
@@ -1669,11 +1669,12 @@ url_file_name (const struct url *u, char *replaced_filename)
2) Retrieval with regetting.
3) Timestamping is used.
4) Hierarchy is built.
+ 5) Backups are specified.
The exception is the case when file does exist and is a
directory (see `mkalldirs' for explanation). */
- if ((opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct)
+ if (ALLOW_CLOBBER
&& !(file_exists_p (fname) && !file_non_directory_p (fname)))
{
unique = fname;
diff --git a/src/url.h b/src/url.h
index b7f4366..cd3782b 100644
--- a/src/url.h
+++ b/src/url.h
@@ -47,6 +47,12 @@ as that of the covered work. */
#define DEFAULT_FTP_PORT 21
#define DEFAULT_HTTPS_PORT 443
+/* The flags that allow clobbering the file (opening with "wb").
+ Defined here to avoid repetition later. #### This will require
+ rework. */
+#define ALLOW_CLOBBER (opt.noclobber || opt.always_rest || opt.timestamping \
+ || opt.dirstruct || opt.output_document || opt.backups > 0)
+
/* Specifies how, or whether, user auth information should be included
* in URLs regenerated from URL parse structures. */
enum url_auth_mode {
--
1.8.3.1

View File

@ -17,6 +17,8 @@ Patch7: wget-1.14-fix-double-free-of-iri-orig_url.patch
Patch8: wget-1.14-Fix-deadcode-and-possible-NULL-use.patch
Patch9: wget-1.14-doc-missing-opts-and-fix-preserve-permissions.patch
Patch10: wget-1.14-set_sock_to_-1_if_no_persistent_conn.patch
Patch11: wget-1.14-document-backups.patch
Patch12: wget-1.14-fix-backups-to-work-as-documented.patch
Provides: webclient
Provides: bundled(gnulib)
@ -46,6 +48,8 @@ support for Proxy servers, and configurability.
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%build
if pkg-config openssl ; then
@ -82,11 +86,12 @@ rm -rf $RPM_BUILD_ROOT
%{_infodir}/*
%changelog
* Fri Jul 12 2013 Tomas Hozza <thozza@redhat.com> - 1.14-8
* Mon Jul 15 2013 Tomas Hozza <thozza@redhat.com> - 1.14-8
- Fix deadcode and possible use of NULL in vprintf (#913153)
- Add documentation for --regex-type and --preserve-permissions
- Fix --preserve-permissions to work as documented (and expected)
- Fix bug when authenticating using user:password@url syntax (#912358)
- Document and fix --backups option
* Wed Jul 10 2013 Tomas Hozza <thozza@redhat.com> - 1.14-7
- Fix double free of iri->orig_url (#981778)