From 714cfe3241855a127b68f5f04a3698d8e67b3c21 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Fri, 15 Aug 2014 11:33:09 +0300 Subject: [PATCH] Fix the adding of .torrent files via http links which was broken by 6f5f661f3. --- src/qtlibtorrent/qbtsession.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index b1330ad6b..3f1393aa1 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1060,7 +1060,12 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr // Check if BT_backup directory exists const QDir torrentBackup(fsutils::BTBackupLocation()); - if (!torrentBackup.exists()) return h; + if (!torrentBackup.exists()) { + // If temporary file, remove it + if (!from_url.isNull() || fromScanDir) + fsutils::forceRemove(path); + return h; + } // Fix the input path if necessary #ifdef Q_WS_WIN @@ -1133,7 +1138,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr // Delete file if temporary if (!from_url.isNull() || fromScanDir) - fsutils::forceRemove(path); + fsutils::forceRemove(path); return h; } @@ -1142,7 +1147,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr addConsoleMessage(tr("Error: The torrent %1 does not contain any file.").arg(misc::toQStringU(t->name()))); // Delete file if temporary if (!from_url.isNull() || fromScanDir) - fsutils::forceRemove(path); + fsutils::forceRemove(path); return h; } @@ -1213,8 +1218,9 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr // Check if it worked if (!h.is_valid()) { qDebug("/!\\ Error: Invalid handle"); - if (!from_url.isNull()) - fsutils::forceRemove(path); + // If temporary file, remove it + if (!from_url.isNull() || fromScanDir) + fsutils::forceRemove(path); return h; } @@ -2870,7 +2876,6 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) { h.pause(); emit newDownloadedTorrentFromRss(url); } - fsutils::forceRemove(file_path); } // Return current download rate for the BT