Fix for #736: do the timeout a better way so it won't stop a working download.

Also add a dialog to alert the user when downloading an add-on fails.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11857 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
red-skull 2012-11-03 22:58:57 +00:00
parent 2a88016c9a
commit 2d93303425
2 changed files with 14 additions and 4 deletions

View File

@ -529,8 +529,16 @@ CURLcode NetworkHttp::downloadFileInternal(Request *request)
&NetworkHttp::progressDownload);
curl_easy_setopt(m_curl_session, CURLOPT_NOPROGRESS, 0);
// 30 sec to timeout, maybe change the value
curl_easy_setopt(m_curl_session, CURLOPT_TIMEOUT, 30);
// Timeout
// Reduce the connection phase timeout (it's 300 by default).
// Add a low speed limit to have a sort of timeout in the
// download phase. Being under 10 B/s during a certain time will
// probably only happen when no access to the net is available.
// The timeout is set to 20s, it should be enough to not produce
// false positive error.
curl_easy_setopt(m_curl_session, CURLOPT_CONNECTTIMEOUT, 20);
curl_easy_setopt(m_curl_session, CURLOPT_LOW_SPEED_LIMIT, 10);
curl_easy_setopt(m_curl_session, CURLOPT_LOW_SPEED_TIME, 20);
CURLcode status = curl_easy_perform(m_curl_session);
fclose(fout);

View File

@ -30,6 +30,7 @@
#include "input/input_manager.hpp"
#include "io/file_manager.hpp"
#include "states_screens/addons_screen.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
@ -190,7 +191,7 @@ void AddonsLoading::init()
// ----------------------------------------------------------------------------
void AddonsLoading::escapePressed()
{
processEvent("cancel");
processEvent("back");
ModalDialog::dismiss();
} // escapePressed
@ -253,7 +254,8 @@ void AddonsLoading::onUpdate(float delta)
{
// Avoid displaying '-100%' in case of an error.
m_progress->setVisible(false);
m_back_button->setText(_("Download failed."));
dismiss();
new MessageDialog( _("Sorry, downloading the add-on failed"));
return;
}
else if(progress>=1.0f)