diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-12-04 20:56:52 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-12-04 20:56:52 +0900 |
| commit | adcfffeccb812596ab231a732bbbb7b20a27a1e4 (patch) | |
| tree | e78c15ab4cc4742773eed66f683b712cb64ee428 /src/RequestGroup.cc | |
| parent | f3e89651a85baa518b4e0d61828eec082f3d1040 (diff) | |
Fixed arithmetic exception when completedLength is 0.
Diffstat (limited to 'src/RequestGroup.cc')
| -rw-r--r-- | src/RequestGroup.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index caa56960..d1cedc1a 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -1201,15 +1201,16 @@ void RequestGroup::reportDownloadFinished() #ifdef ENABLE_BITTORRENT if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) { TransferStat stat = calculateStat(); - double shareRatio = - ((stat.getAllTimeUploadLength()*10)/getCompletedLength())/10.0; + uint64_t completedLength = getCompletedLength(); + double shareRatio = completedLength == 0 ? 0.0 : + 1.0*stat.getAllTimeUploadLength()/completedLength; SharedHandle<TorrentAttribute> attrs = bittorrent::getTorrentAttrs(downloadContext_); if(!attrs->metadata.empty()) { A2_LOG_NOTICE(fmt(MSG_SHARE_RATIO_REPORT, shareRatio, util::abbrevSize(stat.getAllTimeUploadLength()).c_str(), - util::abbrevSize(getCompletedLength()).c_str())); + util::abbrevSize(completedLength).c_str())); } } #endif // ENABLE_BITTORRENT |
