mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
- Got rid of .paused files, useless with new libtorrent
This commit is contained in:
parent
c97bce4d61
commit
a0b4e54410
@ -353,7 +353,7 @@ void bittorrent::loadWebSeeds(QString hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a torrent to the bittorrent session
|
// Add a torrent to the bittorrent session
|
||||||
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
|
QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
|
||||||
QTorrentHandle h;
|
QTorrentHandle h;
|
||||||
bool fastResume=false;
|
bool fastResume=false;
|
||||||
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||||
@ -370,7 +370,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||||||
// Processing torrents
|
// Processing torrents
|
||||||
file = path.trimmed().replace("file://", "", Qt::CaseInsensitive);
|
file = path.trimmed().replace("file://", "", Qt::CaseInsensitive);
|
||||||
if(file.isEmpty()) {
|
if(file.isEmpty()) {
|
||||||
return;
|
return h;
|
||||||
}
|
}
|
||||||
Q_ASSERT(!file.startsWith("http://", Qt::CaseInsensitive) && !file.startsWith("https://", Qt::CaseInsensitive) && !file.startsWith("ftp://", Qt::CaseInsensitive));
|
Q_ASSERT(!file.startsWith("http://", Qt::CaseInsensitive) && !file.startsWith("https://", Qt::CaseInsensitive) && !file.startsWith("ftp://", Qt::CaseInsensitive));
|
||||||
qDebug("Adding %s to download list", file.toUtf8().data());
|
qDebug("Adding %s to download list", file.toUtf8().data());
|
||||||
@ -392,7 +392,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||||||
// Remove file
|
// Remove file
|
||||||
QFile::remove(file);
|
QFile::remove(file);
|
||||||
}
|
}
|
||||||
return;
|
return h;
|
||||||
}
|
}
|
||||||
qDebug(" -> Hash: %s", misc::toString(t->info_hash()).c_str());
|
qDebug(" -> Hash: %s", misc::toString(t->info_hash()).c_str());
|
||||||
qDebug(" -> Name: %s", t->name().c_str());
|
qDebug(" -> Name: %s", t->name().c_str());
|
||||||
@ -422,7 +422,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||||||
// Delete torrent from scan dir
|
// Delete torrent from scan dir
|
||||||
QFile::remove(file);
|
QFile::remove(file);
|
||||||
}
|
}
|
||||||
return;
|
return h;
|
||||||
}
|
}
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
//Getting fast resume data if existing
|
//Getting fast resume data if existing
|
||||||
@ -464,7 +464,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||||||
qDebug("/!\\ Error: Invalid handle");
|
qDebug("/!\\ Error: Invalid handle");
|
||||||
// If download from url, remove temp file
|
// If download from url, remove temp file
|
||||||
if(!from_url.isNull()) QFile::remove(file);
|
if(!from_url.isNull()) QFile::remove(file);
|
||||||
return;
|
return h;
|
||||||
}
|
}
|
||||||
// Connections limit per torrent
|
// Connections limit per torrent
|
||||||
h.set_max_connections(maxConnecsPerTorrent);
|
h.set_max_connections(maxConnecsPerTorrent);
|
||||||
@ -496,7 +496,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||||||
qDebug("Incremental download enabled for %s", t->name().c_str());
|
qDebug("Incremental download enabled for %s", t->name().c_str());
|
||||||
h.set_sequential_download(true);
|
h.set_sequential_download(true);
|
||||||
}
|
}
|
||||||
if((resumed || !addInPause) && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
|
if(!addInPause && !fastResume) {
|
||||||
// Start torrent because it was added in paused state
|
// Start torrent because it was added in paused state
|
||||||
h.resume();
|
h.resume();
|
||||||
}
|
}
|
||||||
@ -519,6 +519,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||||||
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file));
|
addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file));
|
||||||
}
|
}
|
||||||
emit addedTorrent(h);
|
emit addedTorrent(h);
|
||||||
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check in .priorities file if the user filtered files
|
// Check in .priorities file if the user filtered files
|
||||||
|
@ -99,7 +99,7 @@ class bittorrent : public QObject {
|
|||||||
qlonglong getETA(QString hash) const;
|
qlonglong getETA(QString hash) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
|
QTorrentHandle addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
|
||||||
void loadSessionState();
|
void loadSessionState();
|
||||||
void saveSessionState();
|
void saveSessionState();
|
||||||
void downloadFromUrl(QString url);
|
void downloadFromUrl(QString url);
|
||||||
|
@ -319,22 +319,12 @@ void QTorrentHandle::pause() {
|
|||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
h.auto_managed(false);
|
h.auto_managed(false);
|
||||||
h.pause();
|
h.pause();
|
||||||
// Create .paused file if necessary
|
|
||||||
if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused")) {
|
|
||||||
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused");
|
|
||||||
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
|
||||||
paused_file.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::resume() {
|
void QTorrentHandle::resume() {
|
||||||
Q_ASSERT(h.is_valid());
|
Q_ASSERT(h.is_valid());
|
||||||
h.auto_managed(true);
|
h.auto_managed(true);
|
||||||
h.resume();
|
h.resume();
|
||||||
// Delete .paused file if necessary
|
|
||||||
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused")) {
|
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTorrentHandle::remove_url_seed(QString seed) {
|
void QTorrentHandle::remove_url_seed(QString seed) {
|
||||||
|
@ -415,14 +415,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
}else{
|
}else{
|
||||||
QFile::remove(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".incremental"));
|
QFile::remove(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".incremental"));
|
||||||
}
|
}
|
||||||
// Create .paused file if necessary
|
|
||||||
if(addInPause->isChecked()){
|
|
||||||
QFile paused_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"));
|
|
||||||
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
|
||||||
paused_file.close();
|
|
||||||
}else{
|
|
||||||
QFile::remove(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"));
|
|
||||||
}
|
|
||||||
// Check if there is at least one selected file
|
// Check if there is at least one selected file
|
||||||
if(allFiltered()){
|
if(allFiltered()){
|
||||||
QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
|
QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
|
||||||
@ -431,7 +423,9 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||||||
// save filtered files
|
// save filtered files
|
||||||
savePiecesPriorities();
|
savePiecesPriorities();
|
||||||
// Add to download list
|
// Add to download list
|
||||||
BTSession->addTorrent(filePath, false, from_url);
|
QTorrentHandle h = BTSession->addTorrent(filePath, false, from_url);
|
||||||
|
if(addInPause->isChecked() && h.is_valid())
|
||||||
|
h.pause();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user