diff --git a/pageManager.cpp b/pageManager.cpp index ab21845..b056c6d 100644 --- a/pageManager.cpp +++ b/pageManager.cpp @@ -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); - /* get it! */ - if( (res = curl_easy_perform(curl_handle)) != CURLE_OK) { - perror((std::string("\33[2K\r => Error: curl_easy_perform() failed: ") + curl_easy_strerror(res)).c_str()); - return 3; + 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()); + 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) diff --git a/parameterManager.h b/parameterManager.h index fbf0493..dc464fc 100644 --- a/parameterManager.h +++ b/parameterManager.h @@ -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 = "", diff --git a/programManager.cpp b/programManager.cpp index e09b79d..2cb9042 100644 --- a/programManager.cpp +++ b/programManager.cpp @@ -998,13 +998,13 @@ int ProgramManager::updateModus(Settings *settings) std::string line; while (std::getline(strstream, line).good()) { if(line != "") - std::cout << " > " << line << std::endl; + std::cout << " > " << line << std::endl; } //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; }