Ver Fonte

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
Tatsuhiro Tsujikawa há 18 anos atrás
pai
commit
564e8e75fa
5 ficheiros alterados com 31 adições e 2 exclusões
  1. 11 0
      ChangeLog
  2. 16 0
      src/RequestGroup.cc
  3. 2 0
      src/RequestGroup.h
  4. 1 2
      src/RequestGroupMan.cc
  5. 1 0
      src/message.h

+ 11 - 0
ChangeLog

@@ -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

+ 16 - 0
src/RequestGroup.cc

@@ -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
+}

+ 2 - 0
src/RequestGroup.h

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

+ 1 - 2
src/RequestGroupMan.cc

@@ -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 {

+ 1 - 0
src/message.h

@@ -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.")