mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Add option to stop seeding when torrent has been inactive
PR #19294. Closes #533. Closes #8073. Closes #15939.
This commit is contained in:
@@ -258,6 +258,8 @@ void AppController::preferencesAction()
|
||||
data[u"max_ratio"_s] = session->globalMaxRatio();
|
||||
data[u"max_seeding_time_enabled"_s] = (session->globalMaxSeedingMinutes() >= 0.);
|
||||
data[u"max_seeding_time"_s] = session->globalMaxSeedingMinutes();
|
||||
data[u"max_inactive_seeding_time_enabled"_s] = (session->globalMaxInactiveSeedingMinutes() >= 0.);
|
||||
data[u"max_inactive_seeding_time"_s] = session->globalMaxInactiveSeedingMinutes();
|
||||
data[u"max_ratio_act"_s] = session->maxRatioAction();
|
||||
// Add trackers
|
||||
data[u"add_trackers_enabled"_s] = session->isAddTrackersEnabled();
|
||||
@@ -739,6 +741,11 @@ void AppController::setPreferencesAction()
|
||||
else
|
||||
session->setGlobalMaxSeedingMinutes(-1);
|
||||
}
|
||||
if (hasKey(u"max_inactive_seeding_time_enabled"_s))
|
||||
{
|
||||
session->setGlobalMaxInactiveSeedingMinutes(it.value().toBool()
|
||||
? m[u"max_inactive_seeding_time"_s].toInt() : -1);
|
||||
}
|
||||
if (hasKey(u"max_ratio_act"_s))
|
||||
session->setMaxRatioAction(static_cast<MaxRatioAction>(it.value().toInt()));
|
||||
// Add trackers
|
||||
|
||||
@@ -148,9 +148,11 @@ QVariantMap serialize(const BitTorrent::Torrent &torrent)
|
||||
{KEY_TORRENT_AMOUNT_COMPLETED, torrent.completedSize()},
|
||||
{KEY_TORRENT_MAX_RATIO, torrent.maxRatio()},
|
||||
{KEY_TORRENT_MAX_SEEDING_TIME, torrent.maxSeedingTime()},
|
||||
{KEY_TORRENT_MAX_INACTIVE_SEEDING_TIME, torrent.maxInactiveSeedingTime()},
|
||||
{KEY_TORRENT_RATIO, adjustRatio(torrent.realRatio())},
|
||||
{KEY_TORRENT_RATIO_LIMIT, torrent.ratioLimit()},
|
||||
{KEY_TORRENT_SEEDING_TIME_LIMIT, torrent.seedingTimeLimit()},
|
||||
{KEY_TORRENT_INACTIVE_SEEDING_TIME_LIMIT, torrent.inactiveSeedingTimeLimit()},
|
||||
{KEY_TORRENT_LAST_SEEN_COMPLETE_TIME, torrent.lastSeenComplete().toSecsSinceEpoch()},
|
||||
{KEY_TORRENT_AUTO_TORRENT_MANAGEMENT, torrent.isAutoTMMEnabled()},
|
||||
{KEY_TORRENT_TIME_ACTIVE, torrent.activeTime()},
|
||||
|
||||
@@ -79,8 +79,10 @@ inline const QString KEY_TORRENT_AMOUNT_LEFT = u"amount_left"_s;
|
||||
inline const QString KEY_TORRENT_AMOUNT_COMPLETED = u"completed"_s;
|
||||
inline const QString KEY_TORRENT_MAX_RATIO = u"max_ratio"_s;
|
||||
inline const QString KEY_TORRENT_MAX_SEEDING_TIME = u"max_seeding_time"_s;
|
||||
inline const QString KEY_TORRENT_MAX_INACTIVE_SEEDING_TIME = u"max_inactive_seeding_time"_s;
|
||||
inline const QString KEY_TORRENT_RATIO_LIMIT = u"ratio_limit"_s;
|
||||
inline const QString KEY_TORRENT_SEEDING_TIME_LIMIT = u"seeding_time_limit"_s;
|
||||
inline const QString KEY_TORRENT_INACTIVE_SEEDING_TIME_LIMIT = u"inactive_seeding_time_limit"_s;
|
||||
inline const QString KEY_TORRENT_LAST_SEEN_COMPLETE_TIME = u"seen_complete"_s;
|
||||
inline const QString KEY_TORRENT_LAST_ACTIVITY_TIME = u"last_activity"_s;
|
||||
inline const QString KEY_TORRENT_TOTAL_SIZE = u"total_size"_s;
|
||||
|
||||
@@ -673,6 +673,7 @@ void TorrentsController::addAction()
|
||||
const int dlLimit = parseInt(params()[u"dlLimit"_s]).value_or(-1);
|
||||
const double ratioLimit = parseDouble(params()[u"ratioLimit"_s]).value_or(BitTorrent::Torrent::USE_GLOBAL_RATIO);
|
||||
const int seedingTimeLimit = parseInt(params()[u"seedingTimeLimit"_s]).value_or(BitTorrent::Torrent::USE_GLOBAL_SEEDING_TIME);
|
||||
const int inactiveSeedingTimeLimit = parseInt(params()[u"inactiveSeedingTimeLimit"_s]).value_or(BitTorrent::Torrent::USE_GLOBAL_INACTIVE_SEEDING_TIME);
|
||||
const std::optional<bool> autoTMM = parseBool(params()[u"autoTMM"_s]);
|
||||
|
||||
const QString stopConditionParam = params()[u"stopCondition"_s];
|
||||
@@ -720,6 +721,7 @@ void TorrentsController::addAction()
|
||||
addTorrentParams.uploadLimit = upLimit;
|
||||
addTorrentParams.downloadLimit = dlLimit;
|
||||
addTorrentParams.seedingTimeLimit = seedingTimeLimit;
|
||||
addTorrentParams.inactiveSeedingTimeLimit = inactiveSeedingTimeLimit;
|
||||
addTorrentParams.ratioLimit = ratioLimit;
|
||||
addTorrentParams.useAutoTMM = autoTMM;
|
||||
|
||||
@@ -980,16 +982,18 @@ void TorrentsController::setDownloadLimitAction()
|
||||
|
||||
void TorrentsController::setShareLimitsAction()
|
||||
{
|
||||
requireParams({u"hashes"_s, u"ratioLimit"_s, u"seedingTimeLimit"_s});
|
||||
requireParams({u"hashes"_s, u"ratioLimit"_s, u"seedingTimeLimit"_s, u"inactiveSeedingTimeLimit"_s});
|
||||
|
||||
const qreal ratioLimit = params()[u"ratioLimit"_s].toDouble();
|
||||
const qlonglong seedingTimeLimit = params()[u"seedingTimeLimit"_s].toLongLong();
|
||||
const qlonglong inactiveSeedingTimeLimit = params()[u"inactiveSeedingTimeLimit"_s].toLongLong();
|
||||
const QStringList hashes = params()[u"hashes"_s].split(u'|');
|
||||
|
||||
applyToTorrents(hashes, [ratioLimit, seedingTimeLimit](BitTorrent::Torrent *const torrent)
|
||||
applyToTorrents(hashes, [ratioLimit, seedingTimeLimit, inactiveSeedingTimeLimit](BitTorrent::Torrent *const torrent)
|
||||
{
|
||||
torrent->setRatioLimit(ratioLimit);
|
||||
torrent->setSeedingTimeLimit(seedingTimeLimit);
|
||||
torrent->setInactiveSeedingTimeLimit(inactiveSeedingTimeLimit);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user