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