2007-12-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Show the seed ratio after torrent downloads.
	For example, after torrent download completed and --seed-time 
and
	--seed-ratio conditions are fulfilled, following message is 
printed
	right after "Download complete: .....":
	Your share ratio was 1.0, uploaded/downloaded=12M/12M
	* src/RequestGroupMan.cc
	* src/RequestGroup.{h, cc}
	* src/message.h
pull/1/head
Tatsuhiro Tsujikawa 2007-12-29 07:02:35 +00:00
parent 16722b559d
commit 564e8e75fa
5 changed files with 31 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2007-12-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Show the seed ratio after torrent downloads.
For example, after torrent download completed and --seed-time and
--seed-ratio conditions are fulfilled, following message is printed
right after "Download complete: .....":
Your share ratio was 1.0, uploaded/downloaded=12M/12M
* src/RequestGroupMan.cc
* src/RequestGroup.{h, cc}
* src/message.h
2007-12-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Remove a defunct control file. A defunct control file means that while

View File

@ -845,3 +845,19 @@ void RequestGroup::removeURIWhoseHostnameIs(const string& hostname)
_gid, _uris.size()-newURIs.size());
_uris = newURIs;
}
void RequestGroup::reportDownloadFinished()
{
_logger->notice(MSG_FILE_DOWNLOAD_COMPLETED,
getFilePath().c_str());
#ifdef ENABLE_BITTORRENT
TransferStat stat = calculateStat();
if(!BtContextHandle(_downloadContext).isNull()) {
double shareRatio = ((stat.getAllTimeUploadLength()*10)/getCompletedLength())/10.0;
_logger->notice(MSG_SHARE_RATIO_REPORT,
shareRatio,
Util::abbrevSize(stat.getAllTimeUploadLength()).c_str(),
Util::abbrevSize(getCompletedLength()).c_str());
}
#endif // ENABLE_BITTORRENT
}

View File

@ -344,6 +344,8 @@ public:
void removeServerHost(int32_t cuid);
void removeURIWhoseHostnameIs(const string& hostname);
void reportDownloadFinished();
};
typedef SharedHandle<RequestGroup> RequestGroupHandle;

View File

@ -107,8 +107,7 @@ void RequestGroupMan::removeStoppedGroup()
try {
(*itr)->closeFile();
if((*itr)->downloadFinished()) {
_logger->notice(MSG_FILE_DOWNLOAD_COMPLETED,
(*itr)->getFilePath().c_str());
(*itr)->reportDownloadFinished();
if((*itr)->allDownloadFinished()) {
(*itr)->getProgressInfoFile()->removeFile();
} else {

View File

@ -134,6 +134,7 @@
#define MSG_CANNOT_PARSE_METALINK _("Cannot parse metalink XML file. XML may be malformed.")
#define MSG_TOO_SMALL_PAYLOAD_SIZE _("Too small payload size for %s, size=%d.")
#define MSG_REMOVED_DEFUNCT_CONTROL_FILE _("Removed the defunct control file %s because the download file %s doesn't exist.")
#define MSG_SHARE_RATIO_REPORT _("Your share ratio was %.1f, uploaded/downloaded=%s/%s")
#define EX_TIME_OUT _("Timeout.")
#define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")