mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
- Add torrents in pause before applying settings to avoid race conditions
- Started to work on a new function to delete torrents permanently that is safer. Not used yet because it is buggy : it works only for simple cases and I'm not sure I can do better right now with the info libtorrent is providing.
This commit is contained in:
parent
8ce1a4c3df
commit
cfacac7dbf
1
TODO
1
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
|
||||
|
@ -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{
|
||||
|
56
src/misc.h
56
src/misc.h
@ -33,6 +33,7 @@
|
||||
#include <QThread>
|
||||
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
// #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<nbFiles; ++i){
|
||||
// QString fileName = h.file_at(i);
|
||||
// QStringList filters;
|
||||
// filters << fileName;
|
||||
// QFileInfoList files = saveDir.entryInfoList(filters, QDir::Files);
|
||||
// QFileInfo file;
|
||||
// foreach(file, files){
|
||||
// if(file.fileName() == fileName && !file.isSymLink()){
|
||||
// if(!subDir.remove(h.file_at(i))){
|
||||
// success = false;
|
||||
// std::cerr << "Could not delete file in folder at " << (savePath + h.name() + QDir::separator() + h.file_at(i)).toUtf8().data() << '\n';
|
||||
// }else{
|
||||
// qDebug("Deleted file in folder at %s", (savePath + h.name() + QDir::separator() + h.file_at(i)).toUtf8().data());
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// // try to remove topfolder if empty
|
||||
// if(saveDir.rmdir(h.name())){
|
||||
// qDebug("Removed top folder %s", (savePath+h.name()).toUtf8().data());
|
||||
// }else{
|
||||
// std::cerr << "Could not remove top folder " << (savePath+h.name()).toUtf8().data() << ", it was not empty\n";
|
||||
// }
|
||||
// return success;
|
||||
// }
|
||||
|
||||
static QString findFileInDir(QString dir_path, QString fileName) {
|
||||
QDir dir(dir_path);
|
||||
if(dir.exists(fileName)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user