From 3d09f579d0bbee01994ef80474d1680bfe652d26 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Wed, 17 Jun 2015 11:21:41 +0300 Subject: [PATCH 1/2] Fix torrent creation date loss. --- src/core/bittorrent/torrenthandle.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core/bittorrent/torrenthandle.cpp b/src/core/bittorrent/torrenthandle.cpp index 4911e7f95..7337431fe 100644 --- a/src/core/bittorrent/torrenthandle.cpp +++ b/src/core/bittorrent/torrenthandle.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #ifdef Q_OS_WIN @@ -1258,15 +1259,8 @@ bool TorrentHandle::saveTorrentFile(const QString &path) { if (!m_torrentInfo.isValid()) return false; - // TODO: Use libtorrent::create_torrent() here! - - libt::entry meta = libt::bdecode(m_torrentInfo.metadata().data(), - m_torrentInfo.metadata().data() + m_torrentInfo.metadata().size()); - libt::entry torrentEntry(libt::entry::dictionary_t); - torrentEntry["info"] = meta; - QList trackers = m_torrentInfo.trackers(); - if (!trackers.isEmpty()) - torrentEntry["announce"] = trackers.first().nativeEntry().url; + libt::create_torrent torrentCreator(*(m_torrentInfo.nativeInfo())); + libt::entry torrentEntry = torrentCreator.generate(); QVector out; libt::bencode(std::back_inserter(out), torrentEntry); From d76c4554e29c137812fee8ad11eaca145005ec99 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Wed, 17 Jun 2015 12:23:16 +0300 Subject: [PATCH 2/2] Fix MaxRatio ignoring. --- src/core/bittorrent/session.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/bittorrent/session.cpp b/src/core/bittorrent/session.cpp index d27d9e2dc..49a463206 100644 --- a/src/core/bittorrent/session.cpp +++ b/src/core/bittorrent/session.cpp @@ -742,8 +742,13 @@ void Session::processBigRatios() if (torrent->isSeed() && (torrent->ratioLimit() != TorrentHandle::NO_RATIO_LIMIT)) { const qreal ratio = torrent->realRatio(); qreal ratioLimit = torrent->ratioLimit(); - if (ratioLimit == TorrentHandle::USE_GLOBAL_RATIO) - ratioLimit = m_globalMaxRatio; + if (ratioLimit == TorrentHandle::USE_GLOBAL_RATIO) { + // If Global Max Ratio is really set... + if (m_globalMaxRatio >= 0) + ratioLimit = m_globalMaxRatio; + else + continue; + } qDebug("Ratio: %f (limit: %f)", ratio, ratioLimit); Q_ASSERT(ratioLimit >= 0.f); @@ -2149,6 +2154,8 @@ void Session::handleAddTorrentAlert(libtorrent::add_torrent_alert *p) } saveTorrentResumeData(torrent); + if ((torrent->ratioLimit() >= 0) && !m_bigRatioTimer->isActive()) + m_bigRatioTimer->start(); // Send torrent addition signal emit torrentAdded(torrent);