füge 4 sversuche beim downloaden in datei hinzu; v2.5.6

This commit is contained in:
Markus 2019-10-14 18:57:48 +02:00
parent 6233d854c3
commit 2dc779f080
3 changed files with 22 additions and 10 deletions

View File

@ -152,10 +152,23 @@ int PageManager::downLoadToFile(std::string filePath, std::string url)
//Error 404, for example => not found
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, true);

int maxTimeOut = 5;
bool failed = false;
for (int timeout = 1; timeout <= maxTimeOut; ++timeout) {
/* get it! */
if( (res = curl_easy_perform(curl_handle)) != CURLE_OK ) {
//Wenns fehlschlägt error ( + wiederversuchen )
if(timeout == maxTimeOut) {
perror((std::string("\33[2K\r => Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str());
return 3;
failed = true;
} else {
std::cout << std::string( "\33[2K\r => Warning: Versuch " + std::to_string(timeout) + " von " + std::to_string(maxTimeOut) + ": curl_easy_perform() failed: " + curl_easy_strerror(res) )<< std::flush;
sleep(1);
}
} else {
//Sonst ( wenns functioniert) schleife verlassen
break;
}
}

/* close the header file */
@ -167,8 +180,7 @@ int PageManager::downLoadToFile(std::string filePath, std::string url)
/* cleanup curl stuff */
curl_easy_cleanup(curl_handle);


return 0;
return (failed) ? 10 : 0;
}

int PageManager::login(Account account)

View File

@ -61,7 +61,7 @@ struct Settings {
proxy_ip = "127.0.0.1",
languages = "GerDub,GerSub,Eng",
genaueHoster = "",
version = "3.2.5",
version = "3.2.6",
defaultFileVersion="1.6",
outputFilePath = "",
default_checkPath = "",

View File

@ -1004,7 +1004,7 @@ int ProgramManager::updateModus(Settings *settings)

//Vergleiche Versionen:
if( atoi(pageManager.replace(neusteVersion, ".", "").c_str()) <= atoi(pageManager.replace(settings->version, ".", "").c_str()) ) {
std::cout << " => Du benützt bereits die neuste Release-Version." << std::endl;
std::cout << "\n => Du benützt bereits die neuste Release-Version." << std::endl;
return 0;
}

@ -1052,7 +1052,7 @@ int ProgramManager::updateModus(Settings *settings)
<< downloadedFilePath << "' -> '" << exePath << "'" << std::endl;
}

std::cout << " => Update Erfolgreich ausgeführt: '" << settings->version << "' -> '" << neusteVersion << "'" << std::endl;
std::cout << "\n => Update Erfolgreich ausgeführt: '" << settings->version << "' -> '" << neusteVersion << "'" << std::endl;

return 0;
}