]> sjero.net Git - wget/commitdiff
[svn] Don't abort when one URL references more than one file.
authorhniksic <devnull@localhost>
Thu, 13 Dec 2001 19:18:31 +0000 (11:18 -0800)
committerhniksic <devnull@localhost>
Thu, 13 Dec 2001 19:18:31 +0000 (11:18 -0800)
Published in <sxs1yhz0w1m.fsf@florida.arsdigita.de>.

src/ChangeLog
src/recur.c

index b7d4e3e43f2c83cc6565c57125bd3661e7098a23..1ca8b3488182cba7b406b24f00a608a2fe32a7ad 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-13  Hrvoje Niksic  <hniksic@arsdigita.com>
+
+       * recur.c (register_download): Don't abort when one URL references
+       two different files.
+
 2001-12-13  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * http.c (gethttp): Check for conn->scheme, not u->scheme, before
index d712b4dbe063116140ec9d24239d30fd65786877..a970c6982f3d95b55bb7e54b35e78a8cde6a644f 100644 (file)
@@ -746,13 +746,32 @@ register_download (const char *url, const char *file)
       dissociate_urls_from_file (file);
     }
 
+  hash_table_put (dl_file_url_map, xstrdup (file), xstrdup (url));
+
+ url_only:
   /* A URL->FILE mapping is not possible without a FILE->URL mapping.
      If the latter were present, it should have been removed by the
-     above `if'.  */
-  assert (!hash_table_contains (dl_url_file_map, url));
+     above `if'.  So we could write:
+
+         assert (!hash_table_contains (dl_url_file_map, url));
+
+     The above is correct when running in recursive mode where the
+     same URL always resolves to the same file.  But if you do
+     something like:
+
+         wget URL URL
+
+     then the first URL will resolve to "FILE", and the other to
+     "FILE.1".  In that case, FILE.1 will not be found in
+     dl_file_url_map, but URL will still point to FILE in
+     dl_url_file_map.  */
+  if (hash_table_get_pair (dl_url_file_map, url, &old_url, &old_file))
+    {
+      hash_table_remove (dl_url_file_map, url);
+      xfree (old_url);
+      xfree (old_file);
+    }
 
-  hash_table_put (dl_file_url_map, xstrdup (file), xstrdup (url));
- url_only:
   hash_table_put (dl_url_file_map, xstrdup (url), xstrdup (file));
 }