Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ namespace
{
return ((value < 0) || (value == std::numeric_limits<int>::max())) ? 0 : value;
}

Comment thread
TurboTheTurtle marked this conversation as resolved.
Outdated
qlonglong finishedTorrentShareLimitsEta(const ShareLimits &shareLimits, const qlonglong ratioEta
Comment thread
TurboTheTurtle marked this conversation as resolved.
Outdated
, const qlonglong seedingTimeEta, const qlonglong inactiveSeedingTimeEta)
{
const bool matchAll = (shareLimits.mode == ShareLimitsMode::MatchAll);
qlonglong result = (matchAll ? 0 : MAX_ETA);
bool hasLimit = false;

const auto applyEta = [&](const bool enabled, const qlonglong eta)
Comment thread
glassez marked this conversation as resolved.
Outdated
{
if (!enabled)
return;

hasLimit = true;
const qlonglong normalizedEta = std::max<qlonglong>(eta, 0);
Comment thread
glassez marked this conversation as resolved.
Outdated
result = (matchAll ? std::max(result, normalizedEta) : std::min(result, normalizedEta));
};

applyEta((shareLimits.ratioLimit >= 0), ratioEta);
applyEta((shareLimits.seedingTimeLimit >= 0), seedingTimeEta);
applyEta((shareLimits.inactiveSeedingTimeLimit >= 0), inactiveSeedingTimeEta);

return (hasLimit ? result : MAX_ETA);
}
}

// TorrentImpl
Expand Down Expand Up @@ -1422,7 +1446,7 @@ qlonglong TorrentImpl::eta() const
inactiveSeedingTimeEta = std::max<qlonglong>(inactiveSeedingTimeEta, 0);
}

return std::min({ratioEta, seedingTimeEta, inactiveSeedingTimeEta});
return finishedTorrentShareLimitsEta(shareLimits, ratioEta, seedingTimeEta, inactiveSeedingTimeEta);
Comment thread
TurboTheTurtle marked this conversation as resolved.
Outdated
}

if (!speedAverage.download) return MAX_ETA;
Expand Down
Loading