|
@@ -33,16 +33,7 @@
|
|
|
*/
|
|
|
/* copyright --> */
|
|
|
#include "ConsoleStatCalc.h"
|
|
|
-#include "RequestGroupMan.h"
|
|
|
-#include "RequestGroup.h"
|
|
|
-#include "FileAllocationMan.h"
|
|
|
-#include "FileAllocationEntry.h"
|
|
|
-#include "CheckIntegrityMan.h"
|
|
|
-#include "CheckIntegrityEntry.h"
|
|
|
-#include "Util.h"
|
|
|
-#ifdef ENABLE_BITTORRENT
|
|
|
-# include "BtContext.h"
|
|
|
-#endif // ENABLE_BITTORRENT
|
|
|
+
|
|
|
#ifdef HAVE_TERMIOS_H
|
|
|
#include <termios.h>
|
|
|
#endif // HAVE_TERMIOS_H
|
|
@@ -50,6 +41,7 @@
|
|
|
#include <sys/ioctl.h>
|
|
|
#endif // HAVE_SYS_IOCTL_H
|
|
|
#include <unistd.h>
|
|
|
+
|
|
|
#include <iomanip>
|
|
|
#include <iostream>
|
|
|
#include <algorithm>
|
|
@@ -57,6 +49,17 @@
|
|
|
#include <sstream>
|
|
|
#include <iterator>
|
|
|
|
|
|
+#include "RequestGroupMan.h"
|
|
|
+#include "RequestGroup.h"
|
|
|
+#include "FileAllocationMan.h"
|
|
|
+#include "FileAllocationEntry.h"
|
|
|
+#include "CheckIntegrityMan.h"
|
|
|
+#include "CheckIntegrityEntry.h"
|
|
|
+#include "Util.h"
|
|
|
+#ifdef ENABLE_BITTORRENT
|
|
|
+# include "BtContext.h"
|
|
|
+#endif // ENABLE_BITTORRENT
|
|
|
+
|
|
|
namespace aria2 {
|
|
|
|
|
|
static void printProgress(std::ostream& o, const SharedHandle<RequestGroup>& rg)
|
|
@@ -155,8 +158,7 @@ static void printProgressSummary(const std::deque<SharedHandle<RequestGroup> >&
|
|
|
}
|
|
|
|
|
|
ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval):
|
|
|
- _summaryInterval(summaryInterval),
|
|
|
- _summaryIntervalCount(0)
|
|
|
+ _summaryInterval(summaryInterval)
|
|
|
{}
|
|
|
|
|
|
void
|
|
@@ -168,7 +170,6 @@ ConsoleStatCalc::calculateStat(const RequestGroupManHandle& requestGroupMan,
|
|
|
return;
|
|
|
}
|
|
|
_cp.reset();
|
|
|
- ++_summaryIntervalCount;
|
|
|
|
|
|
bool isTTY = isatty(STDOUT_FILENO) == 1;
|
|
|
unsigned short int cols = 80;
|
|
@@ -183,9 +184,9 @@ ConsoleStatCalc::calculateStat(const RequestGroupManHandle& requestGroupMan,
|
|
|
}
|
|
|
std::ostringstream o;
|
|
|
if(requestGroupMan->countRequestGroup() > 0) {
|
|
|
- if(_summaryInterval > 0 && _summaryIntervalCount%_summaryInterval == 0) {
|
|
|
+ if(_lastSummaryNotified.elapsed(_summaryInterval)) {
|
|
|
+ _lastSummaryNotified.reset();
|
|
|
printProgressSummary(requestGroupMan->getRequestGroups(), cols);
|
|
|
- _summaryIntervalCount = 0;
|
|
|
std::cout << "\n";
|
|
|
}
|
|
|
|