forked from markus/S_New4
füge 4 sversuche beim downloaden in datei hinzu; v2.5.6
This commit is contained in:
parent
6233d854c3
commit
2dc779f080
@ -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) {
|
||||
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)
|
||||
|
@ -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 = "",
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user