diff --git a/src/downloader.cpp b/src/downloader.cpp index 4d2c7e3..ef04fc2 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -289,7 +289,6 @@ int Downloader::login() if (!boost::filesystem::remove(Globals::globalConfig.curlConf.sCookiePath)) std::cerr << "Failed to delete " << Globals::globalConfig.curlConf.sCookiePath << std::endl; - //if (!gogWebsite->Login(email, password)) if (!gogWebsite->Login(email, password)) { std::cerr << "HTTP: Login failed" << std::endl; @@ -1555,6 +1554,9 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, // Check all chunks int iChunksRepaired = 0; + int iChunkRetryCount = 0; + int iChunkRetryLimit = 3; + bool bChunkRetryLimitReached = false; for (int i=0; i= iChunkRetryLimit) + { + bChunkRetryLimitReached = true; + } } else { std::cout << "OK\r" << std::flush; + iChunkRetryCount = 0; // reset retry count } free(chunk); res = 1; @@ -1608,10 +1628,17 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, if (Globals::globalConfig.bReport) { - std::string report_line = "Repaired [" + std::to_string(iChunksRepaired) + "/" + std::to_string(chunks) + "] " + filepath; + std::string report_line; + if (bChunkRetryLimitReached) + report_line = "Repair failed: " + filepath; + else + report_line = "Repaired [" + std::to_string(iChunksRepaired) + "/" + std::to_string(chunks) + "] " + filepath; this->report_ofs << report_line << std::endl; } + if (bChunkRetryLimitReached) + return res; + // Set timestamp for downloaded file to same value as file on server long filetime = -1; CURLcode result = curl_easy_getinfo(curlhandle, CURLINFO_FILETIME, &filetime);