Merge pull request #3242 from glassez/hotfixes

Fix some #2892 regressions. Closes #3210.
This commit is contained in:
sledgehammer999 2015-06-17 17:45:14 +03:00
commit 0172ab1f50
2 changed files with 12 additions and 11 deletions

View file

@ -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);

View file

@ -39,6 +39,7 @@
#include <libtorrent/bencode.hpp>
#include <libtorrent/address.hpp>
#include <libtorrent/alert_types.hpp>
#include <libtorrent/create_torrent.hpp>
#include <boost/bind.hpp>
#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<TrackerEntry> 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<char> out;
libt::bencode(std::back_inserter(out), torrentEntry);