From 20a4341e1a47dad4f3f2b80d12546653e7d4f0d3 Mon Sep 17 00:00:00 2001
From: hniksic <devnull@localhost>
Date: Sun, 1 Apr 2001 14:34:40 -0700
Subject: [PATCH] [svn] Wget was ignoring an error when getting a directory
 failed. Fix courtesy Nicolas Lichtmaier.

---
 src/ChangeLog |  6 ++++++
 src/ftp.c     | 20 +++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 7c51b192..f3c7f700 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2001-04-01  Nicolas Lichtmaier <nick@debian.org>
+
+	* ftp.c (ftp_get_listing): Propagate error status.
+	(ftp_retrieve_glob): Use it.
+	(ftp_loop): Ditto.
+
 2001-04-01  Nicolas Lichtmaier <nick@debian.org>
 
 	* main.c (main): Add -C to the string that is the third arg to
diff --git a/src/ftp.c b/src/ftp.c
index 306dae83..ae96df70 100644
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -1170,10 +1170,9 @@ ftp_loop_internal (struct urlinfo *u, struct fileinfo *f, ccon *con)
 
 /* Return the directory listing in a reusable format.  The directory
    is specifed in u->dir.  */
-static struct fileinfo *
-ftp_get_listing (struct urlinfo *u, ccon *con)
+uerr_t
+ftp_get_listing (struct urlinfo *u, ccon *con, struct fileinfo **f)
 {
-  struct fileinfo *f;
   uerr_t err;
   char *olocal = u->local;
   char *list_filename, *ofile;
@@ -1191,9 +1190,9 @@ ftp_get_listing (struct urlinfo *u, ccon *con)
   err = ftp_loop_internal (u, NULL, con);
   u->local = olocal;
   if (err == RETROK)
-    f = ftp_parse_ls (list_filename, con->rs);
+    *f = ftp_parse_ls (list_filename, con->rs);
   else
-    f = NULL;
+    *f = NULL;
   if (opt.remove_listing)
     {
       if (unlink (list_filename))
@@ -1203,7 +1202,7 @@ ftp_get_listing (struct urlinfo *u, ccon *con)
     }
   xfree (list_filename);
   con->cmd &= ~DO_LIST;
-  return f;
+  return err;
 }
 
 static uerr_t ftp_retrieve_dirs PARAMS ((struct urlinfo *, struct fileinfo *,
@@ -1501,7 +1500,9 @@ ftp_retrieve_glob (struct urlinfo *u, ccon *con, int action)
 
   con->cmd |= LEAVE_PENDING;
 
-  orig = ftp_get_listing (u, con);
+  res = ftp_get_listing (u, con, &orig);
+  if (res != RETROK)
+    return res;
   start = orig;
   /* First: weed out that do not conform the global rules given in
      opt.accepts and opt.rejects.  */
@@ -1602,9 +1603,10 @@ ftp_loop (struct urlinfo *u, int *dt)
      opt.htmlify is 0, of course.  :-) */
   if (!*u->file && !opt.recursive)
     {
-      struct fileinfo *f = ftp_get_listing (u, &con);
+      struct fileinfo *f;
+      res = ftp_get_listing (u, &con, &f);
 
-      if (f)
+      if (res == RETROK)
 	{
 	  if (opt.htmlify)
 	    {