diff --git a/Changelog b/Changelog
index 4d843fb5d..8f412b76e 100644
--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,7 @@
- FEATURE: Rewritten parts of the download/search lists to improve performance
- FEATURE: Individual share ratio is now displayed in each torrent properties.
- FEATURE: Tuned default settings to improve download speed
+ - FEATURE: Downloading from an URL will retry 10 times if too many users.
- I18N: Added Norwegian translation
- BUGFIX: Fixed a memory leak when pressing OK in torrent properties
- BUGFIX: Improved code so that GUI never freeze during downloading from an url
@@ -27,6 +28,7 @@
- BUGFIX: Fixed problems that could happen with delete selection action
- BUGFIX: Fixed an arithmetic exception that could happen in ETA calculation
- BUGFIX: Fixed Isohunt search engine
+ - BUGFIX: Fixed download from URL function (was buggy)
- COSMETIC: Now displaying the number of downloads in tab title
- COSMETIC: Redesigned download from url dialog
- COSMETIC: Added a message to warn user that we started download from an url
diff --git a/TODO b/TODO
index 9f8468e93..20930a537 100644
--- a/TODO
+++ b/TODO
@@ -34,5 +34,4 @@
// Before 0.7.0
- Test tracker authentication
- Wait for libtorrent v0.11rc release
-- Fix curl downloader to work with TorrentReactor engine
diff --git a/src/GUI.cpp b/src/GUI.cpp
index 1a8437c67..b2151ac28 100644
--- a/src/GUI.cpp
+++ b/src/GUI.cpp
@@ -216,7 +216,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
// Set search engines names
mininova->setText("Mininova");
piratebay->setText("ThePirateBay");
- reactor->setText("TorrentReactor");
+// reactor->setText("TorrentReactor");
isohunt->setText("Isohunt");
btjunkie->setText("BTJunkie");
meganova->setText("Meganova");
@@ -224,7 +224,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
loadCheckedSearchEngines();
connect(mininova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
connect(piratebay, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
- connect(reactor, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
+// connect(reactor, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
connect(isohunt, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
connect(btjunkie, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
connect(meganova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
@@ -761,8 +761,8 @@ void GUI::saveCheckedSearchEngines(int) const{
lastSearchEngines.write(QByteArray("mininova\n"));
if(piratebay->isChecked())
lastSearchEngines.write(QByteArray("piratebay\n"));
- if(reactor->isChecked())
- lastSearchEngines.write(QByteArray("reactor\n"));
+// if(reactor->isChecked())
+// lastSearchEngines.write(QByteArray("reactor\n"));
if(isohunt->isChecked())
lastSearchEngines.write(QByteArray("isohunt\n"));
if(btjunkie->isChecked())
@@ -893,11 +893,11 @@ void GUI::loadCheckedSearchEngines(){
}else{
piratebay->setChecked(false);
}
- if(searchEnginesList.indexOf("reactor\n") != -1){
- reactor->setChecked(true);
- }else{
- reactor->setChecked(false);
- }
+// if(searchEnginesList.indexOf("reactor\n") != -1){
+// reactor->setChecked(true);
+// }else{
+// reactor->setChecked(false);
+// }
if(searchEnginesList.indexOf("isohunt\n") != -1){
isohunt->setChecked(true);
}else{
@@ -1770,7 +1770,7 @@ void GUI::on_search_button_clicked(){
return;
}
// Getting checked search engines
- if(!mininova->isChecked() && ! piratebay->isChecked() && !reactor->isChecked() && !isohunt->isChecked() && !btjunkie->isChecked() && !meganova->isChecked()){
+ if(!mininova->isChecked() && ! piratebay->isChecked()/* && !reactor->isChecked()*/ && !isohunt->isChecked() && !btjunkie->isChecked() && !meganova->isChecked()){
QMessageBox::critical(0, tr("No seach engine selected"), tr("You must select at least one search engine."));
return;
}
@@ -1784,9 +1784,9 @@ void GUI::on_search_button_clicked(){
if(piratebay->isChecked()){
engineNames << "piratebay";
}
- if(reactor->isChecked()){
- engineNames << "reactor";
- }
+// if(reactor->isChecked()){
+// engineNames << "reactor";
+// }
if(isohunt->isChecked()){
engineNames << "isohunt";
}
diff --git a/src/MainWindow.ui b/src/MainWindow.ui
index 9cb986a72..a5dd67fe5 100644
--- a/src/MainWindow.ui
+++ b/src/MainWindow.ui
@@ -404,13 +404,6 @@
- -
-
-
-
-
-
-
-
diff --git a/src/downloadThread.h b/src/downloadThread.h
index 73b39104e..1faf8effd 100644
--- a/src/downloadThread.h
+++ b/src/downloadThread.h
@@ -49,9 +49,12 @@ class downloadThread : public QThread {
void downloadUrl(const QString& url){
mutex.lock();
+ qDebug("In Download thread function, mutex locked");
url_list << url;
mutex.unlock();
+ qDebug("In Download thread function, mutex unlocked (url added)");
if(!isRunning()){
+ qDebug("In Download thread function, Launching thread (was stopped)");
start();
}
}
@@ -59,12 +62,14 @@ class downloadThread : public QThread {
void run(){
forever{
mutex.lock();
+ qDebug("In Download thread RUN, mutex locked");
if(url_list.size() != 0){
QString url = url_list.takeFirst();
mutex.unlock();
+ qDebug("In Download thread RUN, mutex unlocked (got url)");
CURL *curl;
std::string filePath;
- int return_code;
+ int return_code, response;
// XXX: Trick to get a unique filename
QTemporaryFile *tmpfile = new QTemporaryFile;
if (tmpfile->open()) {
@@ -83,8 +88,10 @@ class downloadThread : public QThread {
fclose(file);
return;
}
+ std::string urlString = url.toStdString();
// Set url to download
- curl_easy_setopt(curl, CURLOPT_URL, (void*) url.toStdString().c_str());
+ curl_easy_setopt(curl, CURLOPT_URL, urlString.c_str());
+ qDebug("Url: %s", urlString.c_str());
// Define our callback to get called when there's data to be written
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
// Set destination file
@@ -104,6 +111,7 @@ class downloadThread : public QThread {
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
// We want error message:
char errorBuffer[CURL_ERROR_SIZE];
+ errorBuffer[0]=0; /* prevent junk from being output */
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
if(return_code){
std::cout << "Error: failed to set error buffer in curl\n";
@@ -111,15 +119,29 @@ class downloadThread : public QThread {
QFile::remove(filePath.c_str());
return;
}
- // Perform Download
- return_code = curl_easy_perform(curl);
+ int retries = 0;
+ bool to_many_users = false;
+ do{
+ // Perform Download
+ return_code = curl_easy_perform(curl);
+ // We want HTTP response code
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response);
+ qDebug("HTTP response code: %d", response);
+ if(response/100 == 5){
+ to_many_users = true;
+ ++retries;
+ SleeperThread::msleep(1000);
+ }
+ }while(to_many_users && retries < 10);
// Cleanup
curl_easy_cleanup(curl);
// Close tmp file
fclose(file);
emit downloadFinished(url, QString(filePath.c_str()), return_code, QString(errorBuffer));
+ qDebug("In Download thread RUN, signal emitted, ErrorBuffer: %s", errorBuffer);
}else{
mutex.unlock();
+ qDebug("In Download thread RUN, mutex unlocked (no urls) -> stopping");
break;
}
}