Преглед изворни кода

2007-10-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	* src/ConsoleStatCalc.cc: Let the user know that aria2 is now 
seeding
	after the download finishes.
Tatsuhiro Tsujikawa пре 18 година
родитељ
комит
fdb2ee28cc
2 измењених фајлова са 30 додато и 12 уклоњено
  1. 5 0
      ChangeLog
  2. 25 12
      src/ConsoleStatCalc.cc

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2007-10-27  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	* src/ConsoleStatCalc.cc: Let the user know that aria2 is now seeding
+	after the download finishes.
+
 2007-10-24  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	* src/Piece.{h, cc}: Added SubPiece infrastructure to track down

+ 25 - 12
src/ConsoleStatCalc.cc

@@ -40,6 +40,9 @@
 #include "CheckIntegrityMan.h"
 #include "CheckIntegrityEntry.h"
 #include "Util.h"
+#ifdef ENABLE_BITTORRENT
+# include "BtContext.h"
+#endif // ENABLE_BITTORRENT
 #include <iomanip>
 
 void
@@ -64,18 +67,28 @@ ConsoleStatCalc::calculateStat(const RequestGroupManHandle& requestGroupMan,
     }
 
     cout << "["
-	 << "#" << firstRequestGroup->getGID() << " "
-	 << "SIZE:"
-	 << Util::abbrevSize(firstRequestGroup->getCompletedLength())
-	 << "B"
-	 << "/"
-	 << Util::abbrevSize(firstRequestGroup->getTotalLength())
-	 << "B";
-    if(firstRequestGroup->getTotalLength() > 0) {
-      cout << "("
-	   << 100*firstRequestGroup->getCompletedLength()/firstRequestGroup->getTotalLength()
-	   << "%)";
-    }
+	 << "#" << firstRequestGroup->getGID() << " ";
+#ifdef ENABLE_BITTORRENT
+    if(firstRequestGroup->downloadFinished() &&
+       !BtContextHandle(firstRequestGroup->getDownloadContext()).isNull()) {
+      cout << "SEEDING" << "(" << "ratio:"
+	   << fixed << setprecision(1) << stat.getAllTimeUploadLength()*1.0/firstRequestGroup->getCompletedLength()
+	   << ")";
+    } else
+#endif // ENABLE_BITTORRENT
+      {
+	cout << "SIZE:"
+	     << Util::abbrevSize(firstRequestGroup->getCompletedLength())
+	     << "B"
+	     << "/"
+	     << Util::abbrevSize(firstRequestGroup->getTotalLength())
+	     << "B";
+	if(firstRequestGroup->getTotalLength() > 0) {
+	  cout << "("
+	       << 100*firstRequestGroup->getCompletedLength()/firstRequestGroup->getTotalLength()
+	       << "%)";
+	}
+      }
     cout << " "
 	 << "CN:"
 	 << firstRequestGroup->getNumConnection();