From a801efcd9678f11fd17c6bb5ce4af5bf9d84eb5a Mon Sep 17 00:00:00 2001 From: Steven Schubiger Date: Thu, 4 Mar 2010 22:09:31 +0100 Subject: [PATCH] Don't delete an input file fetched via FTP. --- src/ChangeLog | 9 +++++++++ src/ftp.c | 2 +- src/retr.c | 17 +++++++++++++++++ src/retr.h | 2 ++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 216a8102..64dd7134 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2010-03-04 Steven Schubiger + + * ftp.c (ftp_loop_internal): Omit input file from being + deleted after retrieval. + + * retr.c (input_file_url): New function. + + * retr.h: Add declaration for input_file_url. + 2010-03-02 Steven Schubiger * retr.c (retrieve_from_file): Improve checking for a URL diff --git a/src/ftp.c b/src/ftp.c index dfe23548..79b23b30 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -1561,7 +1561,7 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con, char **local_fi total_downloaded_bytes += qtyread; numurls++; - if (opt.delete_after) + if (opt.delete_after && !input_file_url (opt.input_filename)) { DEBUGP (("\ Removing file due to --delete-after in ftp_loop_internal():\n")); diff --git a/src/retr.c b/src/retr.c index 74b9dccb..e68bce28 100644 --- a/src/retr.c +++ b/src/retr.c @@ -1189,3 +1189,20 @@ set_local_file (const char **file, const char *default_file) else *file = default_file; } + +/* Return true for an input file's own URL, false otherwise. */ +bool +input_file_url (const char *input_file) +{ + static bool first = true; + + if (input_file + && url_has_scheme (input_file) + && first) + { + first = false; + return true; + } + else + return false; +} diff --git a/src/retr.h b/src/retr.h index f50c9980..e95282f2 100644 --- a/src/retr.h +++ b/src/retr.h @@ -69,4 +69,6 @@ bool url_uses_proxy (struct url *); void set_local_file (const char **, const char *); +bool input_file_url (const char *); + #endif /* RETR_H */ -- 2.39.2