Fix the adding of .torrent files via http links which was broken by 6f5f661f3.

This commit is contained in:
sledgehammer999
2014-08-15 11:33:09 +03:00
parent ddbe5b18d5
commit 714cfe3241

View File

@@ -1060,7 +1060,12 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
// Check if BT_backup directory exists // Check if BT_backup directory exists
const QDir torrentBackup(fsutils::BTBackupLocation()); 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 // Fix the input path if necessary
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@@ -1133,7 +1138,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
// Delete file if temporary // Delete file if temporary
if (!from_url.isNull() || fromScanDir) if (!from_url.isNull() || fromScanDir)
fsutils::forceRemove(path); fsutils::forceRemove(path);
return h; 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()))); addConsoleMessage(tr("Error: The torrent %1 does not contain any file.").arg(misc::toQStringU(t->name())));
// Delete file if temporary // Delete file if temporary
if (!from_url.isNull() || fromScanDir) if (!from_url.isNull() || fromScanDir)
fsutils::forceRemove(path); fsutils::forceRemove(path);
return h; return h;
} }
@@ -1213,8 +1218,9 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
// Check if it worked // Check if it worked
if (!h.is_valid()) { if (!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
if (!from_url.isNull()) // If temporary file, remove it
fsutils::forceRemove(path); if (!from_url.isNull() || fromScanDir)
fsutils::forceRemove(path);
return h; return h;
} }
@@ -2870,7 +2876,6 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) {
h.pause(); h.pause();
emit newDownloadedTorrentFromRss(url); emit newDownloadedTorrentFromRss(url);
} }
fsutils::forceRemove(file_path);
} }
// Return current download rate for the BT // Return current download rate for the BT