diff --git a/TODO b/TODO index f147e6009..65c3f84be 100644 --- a/TODO +++ b/TODO @@ -92,5 +92,6 @@ beta4->beta5 changelog: - BUGFIX: Fixed preview from seeding list - BUGFIX: Fixed Alt+3 & Ctrl+F keyboard shortcuts for third tab - BUGFIX: Improved unicode support +- BUGFIX: Add torrents in pause before applying settings to avoid race conditions - I18N: Updated Italian, Polish, Portuguese, Brazilian, German, Russian, Korean and Spanish translations - COSMETIC: Changed the way progress bars are rendered diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index be3f10994..954c465ad 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -394,14 +394,14 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) { QString savePath = getSavePath(hash); // Adding files to bittorrent session if(has_filtered_files(hash)) { - h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, false); + h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, false, true); int index = fullAllocationModeList.indexOf(hash); if(index == -1) { fullAllocationModeList << hash; } qDebug("Full allocation mode"); }else{ - h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, true); + h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, true, true); qDebug("Compact allocation mode"); } if(!h.is_valid()) { @@ -448,6 +448,8 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) { qDebug("Incremental download enabled for %s", t.name().c_str()); h.set_sequenced_download_threshold(1); } + // Start torrent because it was added in paused state + h.resume(); if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) { finishedTorrents << hash; }else{ diff --git a/src/misc.h b/src/misc.h index 9b4a13b5b..ff71a0bde 100644 --- a/src/misc.h +++ b/src/misc.h @@ -33,6 +33,7 @@ #include #include +// #include "qtorrenthandle.h" using namespace libtorrent; #define MAX_CHAR_TMP 128 @@ -170,6 +171,61 @@ class misc : public QObject{ return true; } + // FIXME: Not used yet because it is buggy +// static bool removeTorrentSavePath(QTorrentHandle h) { +// bool success = true; +// QString savePath = QDir::cleanPath(h.save_path() + QDir::separator()); +// unsigned int nbFiles = h.num_files(); +// QDir saveDir(savePath); +// // Check how many file there are +// if(nbFiles == 1){ +// // Only one file, not in a folder +// QStringList filters; +// filters << h.file_at(0); +// QFileInfoList files = saveDir.entryInfoList(filters, QDir::Files); +// QFileInfo file; +// foreach(file, files){ +// if(file.fileName() == h.file_at(0) && !file.isSymLink()){ +// if(saveDir.remove(h.file_at(0))){ +// qDebug("Deleted only file in torrent at %s", (savePath + h.file_at(0)).toUtf8().data()); +// return true; +// }else{ +// return false; +// } +// } +// } +// std::cerr << "Could not delete only file in torrent at " << (savePath + h.file_at(0)).toUtf8().data() << '\n'; +// return false; +// } +// QDir subDir(savePath + h.name()); +// // Torrent has several files in a subFolder +// for(unsigned int i=0; i