mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 13:28:50 +03:00
- Got rid of .paused files, useless with new libtorrent
This commit is contained in:
parent
c97bce4d61
commit
a0b4e54410
4 changed files with 11 additions and 26 deletions
|
@ -353,7 +353,7 @@ void bittorrent::loadWebSeeds(QString hash) {
|
|||
}
|
||||
|
||||
// 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;
|
||||
bool fastResume=false;
|
||||
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||
|
@ -370,7 +370,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||
// Processing torrents
|
||||
file = path.trimmed().replace("file://", "", Qt::CaseInsensitive);
|
||||
if(file.isEmpty()) {
|
||||
return;
|
||||
return h;
|
||||
}
|
||||
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());
|
||||
|
@ -392,7 +392,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
|
|||
// Remove file
|
||||
QFile::remove(file);
|
||||
}
|
||||
return;
|
||||
return h;
|
||||
}
|
||||
qDebug(" -> Hash: %s", misc::toString(t->info_hash()).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
|
||||
QFile::remove(file);
|
||||
}
|
||||
return;
|
||||
return h;
|
||||
}
|
||||
add_torrent_params p;
|
||||
//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");
|
||||
// If download from url, remove temp file
|
||||
if(!from_url.isNull()) QFile::remove(file);
|
||||
return;
|
||||
return h;
|
||||
}
|
||||
// Connections limit per torrent
|
||||
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());
|
||||
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
|
||||
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));
|
||||
}
|
||||
emit addedTorrent(h);
|
||||
return h;
|
||||
}
|
||||
|
||||
// Check in .priorities file if the user filtered files
|
||||
|
|
|
@ -99,7 +99,7 @@ class bittorrent : public QObject {
|
|||
qlonglong getETA(QString hash) const;
|
||||
|
||||
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 saveSessionState();
|
||||
void downloadFromUrl(QString url);
|
||||
|
|
|
@ -319,22 +319,12 @@ void QTorrentHandle::pause() {
|
|||
Q_ASSERT(h.is_valid());
|
||||
h.auto_managed(false);
|
||||
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() {
|
||||
Q_ASSERT(h.is_valid());
|
||||
h.auto_managed(true);
|
||||
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) {
|
||||
|
|
|
@ -415,14 +415,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||
}else{
|
||||
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
|
||||
if(allFiltered()){
|
||||
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
|
||||
savePiecesPriorities();
|
||||
// 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();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue