From 1f6f1716adfa6fdd5387251593224368de1ab382 Mon Sep 17 00:00:00 2001 From: thalieht Date: Fri, 9 Aug 2019 13:06:16 +0300 Subject: [PATCH] Enable Super Seeding mode once ratio/time limit is reached --- src/base/bittorrent/session.cpp | 12 ++++++++++-- src/base/bittorrent/session.h | 3 ++- src/gui/optionsdialog.ui | 11 +++++------ src/webui/www/private/preferences_content.html | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index a049eb478..f803b6224 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -1529,10 +1529,14 @@ void Session::processShareLimits() LogMsg(tr("'%1' reached the maximum ratio you set. Removed.").arg(torrent->name())); deleteTorrent(torrent->hash()); } - else if (!torrent->isPaused()) { + else if ((m_maxRatioAction == Pause) && !torrent->isPaused()) { torrent->pause(); LogMsg(tr("'%1' reached the maximum ratio you set. Paused.").arg(torrent->name())); } + else if ((m_maxRatioAction == EnableSuperSeeding) && !torrent->isPaused() && !torrent->superSeeding()) { + torrent->setSuperSeeding(true); + LogMsg(tr("'%1' reached the maximum ratio you set. Enabled super seeding for it.").arg(torrent->name())); + } continue; } } @@ -1552,10 +1556,14 @@ void Session::processShareLimits() LogMsg(tr("'%1' reached the maximum seeding time you set. Removed.").arg(torrent->name())); deleteTorrent(torrent->hash()); } - else if (!torrent->isPaused()) { + else if ((m_maxRatioAction == Pause) && !torrent->isPaused()) { torrent->pause(); LogMsg(tr("'%1' reached the maximum seeding time you set. Paused.").arg(torrent->name())); } + else if ((m_maxRatioAction == EnableSuperSeeding) && !torrent->isPaused() && !torrent->superSeeding()) { + torrent->setSuperSeeding(true); + LogMsg(tr("'%1' reached the maximum seeding time you set. Enabled super seeding for it.").arg(torrent->name())); + } } } } diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 8ca0e1db1..529f4e1b9 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -62,7 +62,8 @@ class ResumeDataSavingManager; enum MaxRatioAction { Pause, - Remove + Remove, + EnableSuperSeeding }; enum TorrentExportFolder diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index 7a3bf911c..c19f47549 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -2455,9 +2455,6 @@ false - - Qt::AlignCenter - min @@ -2501,6 +2498,11 @@ Remove them + + + Enable super seeding for them + + @@ -2515,9 +2517,6 @@ false - - Qt::AlignHCenter - 9998.000000000000000 diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 2f89d79dc..14869feb2 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -579,6 +579,7 @@