diff options
Diffstat (limited to 'src/process_url.c')
-rw-r--r-- | src/process_url.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/process_url.c b/src/process_url.c index b6fa730..71fdacd 100644 --- a/src/process_url.c +++ b/src/process_url.c @@ -1,3 +1,4 @@ +#include "constants.h" #include <curl/curl.h> #include <curl/easy.h> #include <curl/header.h> @@ -46,7 +47,6 @@ static CURLU *h; static bool logerr_b(CURLcode r) { if (r && !corrupted) { LOG("libcurl", "Error %d: %s\n", r, ERRTOSTRING(r)); - corrupted = true; } return r; } @@ -84,7 +84,6 @@ static bool logerr_h(CURLHcode r) { break; } LOG("libcurl", "Header Error %d: %s\n", r, err_str); - corrupted = true; } return r; } @@ -292,7 +291,7 @@ static int pull_part(void *a) { sprintf(curl_c->partfn.str[n], "%s.%d", curl_c->outfn, n); DEBUG_PRINT("[THRD %hhu] partfn: %s, range: %s\n", n, get_str_element(&curl_c->partfn, n), ti->range); - { + for (unsigned char retry = 0;; retry++) { curl_c->fplist[n] = fopen(get_str_element(&curl_c->partfn, n), "wb+"); CURL *curl; @@ -313,6 +312,14 @@ static int pull_part(void *a) { append_log("[THRD %hhu] File downloaded.\n", n); curl_easy_cleanup(curl); logerr(res); + if (!res) { + break; + } + if (retry + 1 == MAX_RETRY) { + append_log("Error after %d retries, exiting...\n", MAX_RETRY); + corrupted = true; + break; + } } mtx_lock(&mtx); curl_c->success_thrd += 1; |