mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 01:44:26 +00:00
- Fixed download from url function (should be a lot less buggy). It improves downloads from search engine since it uses this function
- Removed torrentReactor search engine (hopefully temporarilly) because I can't manage to download from their links using libcurl - When HTTP response code is 500 (5xx in fact: too busy), downloader will retry 10 times every second.
This commit is contained in:
parent
b54e40c87d
commit
a072247e70
@ -13,6 +13,7 @@
|
|||||||
- FEATURE: Rewritten parts of the download/search lists to improve performance
|
- FEATURE: Rewritten parts of the download/search lists to improve performance
|
||||||
- FEATURE: Individual share ratio is now displayed in each torrent properties.
|
- FEATURE: Individual share ratio is now displayed in each torrent properties.
|
||||||
- FEATURE: Tuned default settings to improve download speed
|
- 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
|
- I18N: Added Norwegian translation
|
||||||
- BUGFIX: Fixed a memory leak when pressing OK in torrent properties
|
- BUGFIX: Fixed a memory leak when pressing OK in torrent properties
|
||||||
- BUGFIX: Improved code so that GUI never freeze during downloading from an url
|
- 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 problems that could happen with delete selection action
|
||||||
- BUGFIX: Fixed an arithmetic exception that could happen in ETA calculation
|
- BUGFIX: Fixed an arithmetic exception that could happen in ETA calculation
|
||||||
- BUGFIX: Fixed Isohunt search engine
|
- BUGFIX: Fixed Isohunt search engine
|
||||||
|
- BUGFIX: Fixed download from URL function (was buggy)
|
||||||
- COSMETIC: Now displaying the number of downloads in tab title
|
- COSMETIC: Now displaying the number of downloads in tab title
|
||||||
- COSMETIC: Redesigned download from url dialog
|
- COSMETIC: Redesigned download from url dialog
|
||||||
- COSMETIC: Added a message to warn user that we started download from an url
|
- COSMETIC: Added a message to warn user that we started download from an url
|
||||||
|
1
TODO
1
TODO
@ -34,5 +34,4 @@
|
|||||||
// Before 0.7.0
|
// Before 0.7.0
|
||||||
- Test tracker authentication
|
- Test tracker authentication
|
||||||
- Wait for libtorrent v0.11rc release
|
- Wait for libtorrent v0.11rc release
|
||||||
- Fix curl downloader to work with TorrentReactor engine
|
|
||||||
|
|
||||||
|
26
src/GUI.cpp
26
src/GUI.cpp
@ -216,7 +216,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
// Set search engines names
|
// Set search engines names
|
||||||
mininova->setText("Mininova");
|
mininova->setText("Mininova");
|
||||||
piratebay->setText("ThePirateBay");
|
piratebay->setText("ThePirateBay");
|
||||||
reactor->setText("TorrentReactor");
|
// reactor->setText("TorrentReactor");
|
||||||
isohunt->setText("Isohunt");
|
isohunt->setText("Isohunt");
|
||||||
btjunkie->setText("BTJunkie");
|
btjunkie->setText("BTJunkie");
|
||||||
meganova->setText("Meganova");
|
meganova->setText("Meganova");
|
||||||
@ -224,7 +224,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
loadCheckedSearchEngines();
|
loadCheckedSearchEngines();
|
||||||
connect(mininova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
|
connect(mininova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
|
||||||
connect(piratebay, 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(isohunt, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
|
||||||
connect(btjunkie, 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)));
|
connect(meganova, SIGNAL(stateChanged(int)), this, SLOT(saveCheckedSearchEngines(int)));
|
||||||
@ -761,8 +761,8 @@ void GUI::saveCheckedSearchEngines(int) const{
|
|||||||
lastSearchEngines.write(QByteArray("mininova\n"));
|
lastSearchEngines.write(QByteArray("mininova\n"));
|
||||||
if(piratebay->isChecked())
|
if(piratebay->isChecked())
|
||||||
lastSearchEngines.write(QByteArray("piratebay\n"));
|
lastSearchEngines.write(QByteArray("piratebay\n"));
|
||||||
if(reactor->isChecked())
|
// if(reactor->isChecked())
|
||||||
lastSearchEngines.write(QByteArray("reactor\n"));
|
// lastSearchEngines.write(QByteArray("reactor\n"));
|
||||||
if(isohunt->isChecked())
|
if(isohunt->isChecked())
|
||||||
lastSearchEngines.write(QByteArray("isohunt\n"));
|
lastSearchEngines.write(QByteArray("isohunt\n"));
|
||||||
if(btjunkie->isChecked())
|
if(btjunkie->isChecked())
|
||||||
@ -893,11 +893,11 @@ void GUI::loadCheckedSearchEngines(){
|
|||||||
}else{
|
}else{
|
||||||
piratebay->setChecked(false);
|
piratebay->setChecked(false);
|
||||||
}
|
}
|
||||||
if(searchEnginesList.indexOf("reactor\n") != -1){
|
// if(searchEnginesList.indexOf("reactor\n") != -1){
|
||||||
reactor->setChecked(true);
|
// reactor->setChecked(true);
|
||||||
}else{
|
// }else{
|
||||||
reactor->setChecked(false);
|
// reactor->setChecked(false);
|
||||||
}
|
// }
|
||||||
if(searchEnginesList.indexOf("isohunt\n") != -1){
|
if(searchEnginesList.indexOf("isohunt\n") != -1){
|
||||||
isohunt->setChecked(true);
|
isohunt->setChecked(true);
|
||||||
}else{
|
}else{
|
||||||
@ -1770,7 +1770,7 @@ void GUI::on_search_button_clicked(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Getting checked search engines
|
// 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."));
|
QMessageBox::critical(0, tr("No seach engine selected"), tr("You must select at least one search engine."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1784,9 +1784,9 @@ void GUI::on_search_button_clicked(){
|
|||||||
if(piratebay->isChecked()){
|
if(piratebay->isChecked()){
|
||||||
engineNames << "piratebay";
|
engineNames << "piratebay";
|
||||||
}
|
}
|
||||||
if(reactor->isChecked()){
|
// if(reactor->isChecked()){
|
||||||
engineNames << "reactor";
|
// engineNames << "reactor";
|
||||||
}
|
// }
|
||||||
if(isohunt->isChecked()){
|
if(isohunt->isChecked()){
|
||||||
engineNames << "isohunt";
|
engineNames << "isohunt";
|
||||||
}
|
}
|
||||||
|
@ -404,13 +404,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="reactor" >
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="isohunt" >
|
<widget class="QCheckBox" name="isohunt" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
|
@ -49,9 +49,12 @@ class downloadThread : public QThread {
|
|||||||
|
|
||||||
void downloadUrl(const QString& url){
|
void downloadUrl(const QString& url){
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
qDebug("In Download thread function, mutex locked");
|
||||||
url_list << url;
|
url_list << url;
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
qDebug("In Download thread function, mutex unlocked (url added)");
|
||||||
if(!isRunning()){
|
if(!isRunning()){
|
||||||
|
qDebug("In Download thread function, Launching thread (was stopped)");
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,12 +62,14 @@ class downloadThread : public QThread {
|
|||||||
void run(){
|
void run(){
|
||||||
forever{
|
forever{
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
qDebug("In Download thread RUN, mutex locked");
|
||||||
if(url_list.size() != 0){
|
if(url_list.size() != 0){
|
||||||
QString url = url_list.takeFirst();
|
QString url = url_list.takeFirst();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
qDebug("In Download thread RUN, mutex unlocked (got url)");
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
std::string filePath;
|
std::string filePath;
|
||||||
int return_code;
|
int return_code, response;
|
||||||
// XXX: Trick to get a unique filename
|
// XXX: Trick to get a unique filename
|
||||||
QTemporaryFile *tmpfile = new QTemporaryFile;
|
QTemporaryFile *tmpfile = new QTemporaryFile;
|
||||||
if (tmpfile->open()) {
|
if (tmpfile->open()) {
|
||||||
@ -83,8 +88,10 @@ class downloadThread : public QThread {
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
std::string urlString = url.toStdString();
|
||||||
// Set url to download
|
// 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
|
// Define our callback to get called when there's data to be written
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, misc::my_fwrite);
|
||||||
// Set destination file
|
// Set destination file
|
||||||
@ -104,6 +111,7 @@ class downloadThread : public QThread {
|
|||||||
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
|
||||||
// We want error message:
|
// We want error message:
|
||||||
char errorBuffer[CURL_ERROR_SIZE];
|
char errorBuffer[CURL_ERROR_SIZE];
|
||||||
|
errorBuffer[0]=0; /* prevent junk from being output */
|
||||||
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
|
return_code = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorBuffer);
|
||||||
if(return_code){
|
if(return_code){
|
||||||
std::cout << "Error: failed to set error buffer in curl\n";
|
std::cout << "Error: failed to set error buffer in curl\n";
|
||||||
@ -111,15 +119,29 @@ class downloadThread : public QThread {
|
|||||||
QFile::remove(filePath.c_str());
|
QFile::remove(filePath.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Perform Download
|
int retries = 0;
|
||||||
return_code = curl_easy_perform(curl);
|
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
|
// Cleanup
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
// Close tmp file
|
// Close tmp file
|
||||||
fclose(file);
|
fclose(file);
|
||||||
emit downloadFinished(url, QString(filePath.c_str()), return_code, QString(errorBuffer));
|
emit downloadFinished(url, QString(filePath.c_str()), return_code, QString(errorBuffer));
|
||||||
|
qDebug("In Download thread RUN, signal emitted, ErrorBuffer: %s", errorBuffer);
|
||||||
}else{
|
}else{
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
qDebug("In Download thread RUN, mutex unlocked (no urls) -> stopping");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user