2007-07-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Create directory structure specified in metalink file.
	* src/RequestGroup.h, src/RequestGroup.cc
	(initAndOpenFile): Create a directory to store files if it does 
not
	exist.
	(getDir): New function.

	Added ETA and download speed for an individual file to readout.
	* src/ConsoleDownloadEngine.cc (sendStatistics)
	* src/RequestGroup.h
	(calculateDownloadSpeed): New function.
pull/1/head
Tatsuhiro Tsujikawa 2007-07-01 14:19:15 +00:00
parent 055c9e0b21
commit a19cf91f9b
4 changed files with 35 additions and 4 deletions

View File

@ -6,6 +6,11 @@
exist. exist.
(getDir): New function. (getDir): New function.
Added ETA and download speed for an individual file to readout.
* src/ConsoleDownloadEngine.cc (sendStatistics)
* src/RequestGroup.h
(calculateDownloadSpeed): New function.
2007-06-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2007-06-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Made -S option work with metalink file and provided selective download Made -S option work with metalink file and provided selective download

View File

@ -61,6 +61,12 @@ void ConsoleDownloadEngine::sendStatistics(long long int currentSize, long long
cout << "\r"; cout << "\r";
if(_requestGroupMan->countRequestGroup() > 0) { if(_requestGroupMan->countRequestGroup() > 0) {
RequestGroupHandle firstRequestGroup = _requestGroupMan->getRequestGroup(0); RequestGroupHandle firstRequestGroup = _requestGroupMan->getRequestGroup(0);
int32_t dlSpeed = firstRequestGroup->calculateDownloadSpeed();
int32_t eta = 0;
if(firstRequestGroup->getTotalLength() > 0 && dlSpeed > 0) {
eta = (firstRequestGroup->getTotalLength()-firstRequestGroup->getDownloadLength())/dlSpeed;
}
cout << "[" cout << "["
<< "#" << firstRequestGroup->getGID() << " " << "#" << firstRequestGroup->getGID() << " "
<< Util::abbrevSize(firstRequestGroup->getDownloadLength()) << Util::abbrevSize(firstRequestGroup->getDownloadLength())
@ -76,6 +82,15 @@ void ConsoleDownloadEngine::sendStatistics(long long int currentSize, long long
cout << "(" cout << "("
<< firstRequestGroup->numConnection << firstRequestGroup->numConnection
<< "cn)"; << "cn)";
cout << "("
<< fixed << setprecision(2)
<< dlSpeed/1024.0 << "KiB/s"
<< ")";
if(eta > 0) {
cout << " "
<< "ETA:"
<< Util::secfmt(eta);
}
if(_requestGroupMan->countRequestGroup() > 1) { if(_requestGroupMan->countRequestGroup() > 1) {
cout << "(" cout << "("
<< _requestGroupMan->countRequestGroup()-1 << _requestGroupMan->countRequestGroup()-1
@ -83,12 +98,17 @@ void ConsoleDownloadEngine::sendStatistics(long long int currentSize, long long
} }
cout << "]"; cout << "]";
} }
cout << "[" << fixed << setprecision(2) << speed/1024.0 << "KiB/s" << "]";
if(_requestGroupMan->countRequestGroup() > 1) {
cout << " "
<< "[" << fixed << setprecision(2) << speed/1024.0 << "KiB/s" << "]";
}
{ {
FileAllocationEntryHandle entry = _fileAllocationMan->getCurrentFileAllocationEntry(); FileAllocationEntryHandle entry = _fileAllocationMan->getCurrentFileAllocationEntry();
if(!entry.isNull()) { if(!entry.isNull()) {
cout << "[FileAlloc:" cout << " "
<< "[FileAlloc:"
<< "#" << entry->getRequestGroup()->getGID() << " " << "#" << entry->getRequestGroup()->getGID() << " "
<< Util::abbrevSize(entry->getCurrentLength()) << Util::abbrevSize(entry->getCurrentLength())
<< "B" << "B"
@ -109,7 +129,8 @@ void ConsoleDownloadEngine::sendStatistics(long long int currentSize, long long
{ {
CheckIntegrityEntryHandle entry = _checkIntegrityMan->getFirstCheckIntegrityEntry(); CheckIntegrityEntryHandle entry = _checkIntegrityMan->getFirstCheckIntegrityEntry();
if(!entry.isNull()) { if(!entry.isNull()) {
cout << "[Checksum:" cout << " "
<< "[Checksum:"
<< "#" << entry->getRequestGroup()->getGID() << " " << "#" << entry->getRequestGroup()->getGID() << " "
<< Util::abbrevSize(entry->getCurrentLength()) << Util::abbrevSize(entry->getCurrentLength())
<< "B" << "B"

View File

@ -53,7 +53,7 @@ DownloadCommand::DownloadCommand(int cuid,
transferDecoder(0) transferDecoder(0)
{ {
peerStat = _requestGroup->getSegmentMan()->getPeerStat(cuid); peerStat = _requestGroup->getSegmentMan()->getPeerStat(cuid);
if(!peerStat.get()) { if(peerStat.isNull()) {
peerStat = new PeerStat(cuid); peerStat = new PeerStat(cuid);
_requestGroup->getSegmentMan()->registerPeerStat(peerStat); _requestGroup->getSegmentMan()->registerPeerStat(peerStat);
} }

View File

@ -296,6 +296,11 @@ public:
{ {
_topDir = topDir; _topDir = topDir;
} }
int32_t calculateDownloadSpeed() const
{
return _segmentMan->calculateDownloadSpeed();
}
}; };
typedef SharedHandle<RequestGroup> RequestGroupHandle; typedef SharedHandle<RequestGroup> RequestGroupHandle;