From 2dc779f0801b045b44e776948e382b0d50a8a2d6 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 14 Oct 2019 18:57:48 +0200 Subject: [PATCH] =?UTF-8?q?f=C3=BCge=204=20sversuche=20beim=20downloaden?= =?UTF-8?q?=20in=20datei=20hinzu;=20v2.5.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pageManager.cpp | 24 ++++++++++++++++++------ parameterManager.h | 2 +- programManager.cpp | 6 +++--- 3 files changed, 22 insertions(+), 10 deletions(-) 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; }