From 298f1e6a9a9c7eb1860198e0c07aeaab10e66d4d Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Fri, 21 Aug 2009 11:26:58 +0000 Subject: [PATCH] - FEATURE: If a torrent contains a torrent file, process downloaded torrent file too --- Changelog | 2 +- src/bittorrent.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 5c1892c4a..3f8a94587 100644 --- a/Changelog +++ b/Changelog @@ -6,7 +6,7 @@ - FEATURE: Display free disk space in torrent addition dialog - FEATURE: In torrent addition from URL, paste clipboard content if it contains an URL - FEATURE: RSS Feeds URLs can now be copied to clipboard - - FEATURE: If a torrent contains a torrent file, process downloaded torrent file too [TODO] + - FEATURE: If a torrent contains a torrent file, process downloaded torrent file too - BUGFIX: torrent resume code rewrited * Thu Aug 13 2009 - Christophe Dumez - v1.4.0 diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 5e7149f4d..f613f7d11 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1251,6 +1251,23 @@ void bittorrent::readAlerts() { } } h.save_resume_data(); + // Check if there is a single torrent file inside + QString torrent_relpath = misc::toQString(h.get_torrent_info().file_at(0).path); + if(torrent_relpath.endsWith(".torrent")) { + addConsoleMessage(tr("Recursive download of file %1 embedded in torrent %2", "Recursive download of test.torrent embedded in torrent test2").arg(torrent_relpath).arg(h.name())); + QString torrent_fullpath = h.save_path()+QDir::separator()+torrent_relpath; + boost::intrusive_ptr t; + try { + t = new torrent_info(torrent_fullpath.toLocal8Bit().data()); + QString sub_hash = misc::toQString(t->info_hash()); + // Passing the save path along to the sub torrent file + TorrentTempData::setSavePath(sub_hash, h.save_path()); + addTorrent(torrent_fullpath); + } catch(std::exception&) { + qDebug("Caught error loading torrent"); + addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(torrent_fullpath), QString::fromUtf8("red")); + } + } qDebug("Received finished alert for %s", h.name().toLocal8Bit().data()); } }