File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1384,7 +1384,32 @@ qlonglong TorrentImpl::totalUpload() const
13841384
13851385qlonglong TorrentImpl::eta () const
13861386{
1387- if (isStopped ()) return MAX_ETA ;
1387+ if (isStopped ())
1388+ {
1389+ if (!isFinished ())
1390+ return MAX_ETA ;
1391+
1392+ const ShareLimits shareLimits = effectiveShareLimits ();
1393+ const bool hasRatioLimit = (shareLimits.ratioLimit >= 0 );
1394+ const bool hasSeedingTimeLimit = (shareLimits.seedingTimeLimit >= 0 );
1395+ const bool hasInactiveSeedingTimeLimit = (shareLimits.inactiveSeedingTimeLimit >= 0 );
1396+ if (!hasRatioLimit && !hasSeedingTimeLimit && !hasInactiveSeedingTimeLimit)
1397+ return MAX_ETA ;
1398+
1399+ const bool ratioLimitReached = !hasRatioLimit || (realRatio () >= shareLimits.ratioLimit );
1400+ const bool seedingTimeLimitReached = !hasSeedingTimeLimit
1401+ || ((finishedTime () / 60 ) >= shareLimits.seedingTimeLimit );
1402+ const bool inactiveSeedingTimeLimitReached = !hasInactiveSeedingTimeLimit
1403+ || ((timeSinceActivity () / 60 ) >= shareLimits.inactiveSeedingTimeLimit );
1404+
1405+ const bool shareLimitsReached = (shareLimits.mode == ShareLimitsMode::MatchAny)
1406+ ? ((hasRatioLimit && ratioLimitReached)
1407+ || (hasSeedingTimeLimit && seedingTimeLimitReached)
1408+ || (hasInactiveSeedingTimeLimit && inactiveSeedingTimeLimitReached))
1409+ : (ratioLimitReached && seedingTimeLimitReached && inactiveSeedingTimeLimitReached);
1410+
1411+ return shareLimitsReached ? 0 : MAX_ETA ;
1412+ }
13881413
13891414 const SpeedSampleAvg speedAverage = m_payloadRateMonitor.average ();
13901415
You can’t perform that action at this time.
0 commit comments