From 8f69f44bb13342e2f552b97a9312f6d89ba2399d Mon Sep 17 00:00:00 2001 From: Sude Date: Mon, 17 Feb 2020 19:18:14 +0200 Subject: [PATCH] Check for HTTP response code 416 in Downloader::repairFile --- src/downloader.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index 9f9532a..730b501 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -1268,10 +1268,17 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, std::cout << "Downloading: " << filepath << std::endl; CURLcode result = this->downloadFile(url, filepath, xml_data, gamename); std::cout << std::endl; + long int response_code = 0; + if (result == CURLE_HTTP_RETURNED_ERROR) + { + curl_easy_getinfo(curlhandle, CURLINFO_RESPONSE_CODE, &response_code); + } if ( - (!bFileExists && result == CURLE_OK) || /* File doesn't exist so only accept if everything was OK */ - (bFileExists && (result == CURLE_OK || result == CURLE_RANGE_ERROR )) /* File exists so accept also CURLE_RANGE_ERROR because curl will return CURLE_RANGE_ERROR */ - ) /* if the file is already fully downloaded and we want to resume it */ + /* File doesn't exist so only accept if everything was OK */ + (!bFileExists && result == CURLE_OK) || + /* File exists so also accept CURLE_RANGE_ERROR and response code 416 */ + (bFileExists && (result == CURLE_OK || result == CURLE_RANGE_ERROR || response_code == 416)) + ) { bLocalXMLExists = boost::filesystem::exists(xml_file); // Check to see if downloadFile saved XML data