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 //Error 404, for example => not found
curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, true); curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, true);


/* get it! */ int maxTimeOut = 5;
if( (res = curl_easy_perform(curl_handle)) != CURLE_OK) { bool failed = false;
perror((std::string("\33[2K\r => Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str()); for (int timeout = 1; timeout <= maxTimeOut; ++timeout) {
return 3; /* 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());
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 */ /* close the header file */
@ -167,8 +180,7 @@ int PageManager::downLoadToFile(std::string filePath, std::string url)
/* cleanup curl stuff */ /* cleanup curl stuff */
curl_easy_cleanup(curl_handle); curl_easy_cleanup(curl_handle);



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


int PageManager::login(Account account) int PageManager::login(Account account)

View File

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

View File

@ -998,13 +998,13 @@ int ProgramManager::updateModus(Settings *settings)
std::string line; std::string line;
while (std::getline(strstream, line).good()) { while (std::getline(strstream, line).good()) {
if(line != "") if(line != "")
std::cout << " > " << line << std::endl; std::cout << " > " << line << std::endl;
} }




//Vergleiche Versionen: //Vergleiche Versionen:
if( atoi(pageManager.replace(neusteVersion, ".", "").c_str()) <= atoi(pageManager.replace(settings->version, ".", "").c_str()) ) { 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; return 0;
} }


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