Return true if completedLength is 0.

pull/1/head
Tatsuhiro Tsujikawa 2010-12-04 20:56:14 +09:00
parent c5ef9dadbd
commit f3e89651a8
1 changed files with 4 additions and 5 deletions

View File

@ -51,13 +51,12 @@ void ShareRatioSeedCriteria::reset() {}
bool ShareRatioSeedCriteria::evaluate()
{
if(downloadContext_->getTotalLength() == 0) {
return false;
uint64_t completedLength = pieceStorage_->getCompletedLength();
if(completedLength == 0) {
return true;
}
TransferStat stat = peerStorage_->calculateStat();
return ratio_ <=
static_cast<double>(stat.getAllTimeUploadLength())/
pieceStorage_->getCompletedLength();
return ratio_ <= 1.0*stat.getAllTimeUploadLength()/completedLength;
}