@@ -239,7 +239,8 @@ static void LinkTable_uninitialised_fill(LinkTable *linktbl)
239239 u = 0 ;
240240 for (int i = 0 ; i < linktbl -> num ; i ++ ) {
241241 Link * this_link = linktbl -> links [i ];
242- if (this_link -> type == LINK_UNINITIALISED_FILE ) {
242+ if (this_link -> type == LINK_UNINITIALISED_FILE ||
243+ this_link -> type == LINK_UNINITIALISED_DIR ) {
243244 Link_req_file_stat (linktbl -> links [i ]);
244245 u ++ ;
245246 }
@@ -365,7 +366,7 @@ static LinkType linkname_to_LinkType(const char *linkname)
365366
366367 /* '/' must be at the end to be a valid directory name */
367368 if (linkname [strnlen (linkname , MAX_FILENAME_LEN ) - 1 ] == '/' ) {
368- return LINK_DIR ;
369+ return LINK_UNINITIALISED_DIR ;
369370 }
370371
371372 return LINK_UNINITIALISED_FILE ;
@@ -429,7 +430,7 @@ static void HTML_to_LinkTable(const char *url, GumboNode *node,
429430 LinkType type = linkname_to_LinkType (relative_url );
430431
431432 /* Check if the new link is a duplicate */
432- if ((type == LINK_DIR ) || (type == LINK_UNINITIALISED_FILE )) {
433+ if ((type == LINK_UNINITIALISED_DIR ) || (type == LINK_UNINITIALISED_FILE )) {
433434 int identical_link_found = 0 ;
434435 for (int i = 0 ; i < linktbl -> num ; i ++ ) {
435436 if (linknames_equal (relative_url , linktbl -> links [i ]-> linkname )) {
@@ -471,16 +472,22 @@ void Link_set_file_stat(Link *this_link, CURL *curl)
471472 if (ret ) {
472473 lprintf (error , "%s" , curl_easy_strerror (ret ));
473474 }
474- if (cl < 0 ) {
475- this_link -> type = LINK_INVALID ;
476- } else if (cl == 0 && CONFIG .zero_len_is_dir ) {
475+
476+ if (this_link -> type == LINK_UNINITIALISED_FILE ) {
477+ if (cl < 0 ) {
478+ this_link -> type = LINK_INVALID ;
479+ } else if (cl == 0 && CONFIG .zero_len_is_dir ) {
480+ this_link -> type = LINK_DIR ;
481+ } else {
482+ this_link -> type = LINK_FILE ;
483+ this_link -> content_length = cl ;
484+ }
485+ } else if (this_link -> type == LINK_UNINITIALISED_DIR ) {
477486 this_link -> type = LINK_DIR ;
478- } else {
479- this_link -> type = LINK_FILE ;
480- this_link -> content_length = cl ;
481487 }
488+
482489 } else {
483- lprintf (warning , "HTTP %ld\n" , http_resp );
490+ lprintf (warning , "%s: HTTP %ld\n" , this_link -> f_url , http_resp );
484491 if (HTTP_temp_failure (http_resp ) || CONFIG .invalid_refresh ) {
485492 lprintf (warning , ", retrying later.\n" );
486493 } else {
0 commit comments