mirror of https://github.com/aria2/aria2
2008-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Show an average download speed in Download results. * src/BtFileAllocationEntry.cc * src/DefaultPieceStorage.cc * src/DownloadContext.cc * src/DownloadContext.h * src/DownloadResult.h * src/RequestGroup.cc * src/RequestGroupMan.cc * src/StreamFileAllocationEntry.ccpull/1/head
parent
82b80c33d8
commit
bdff264d2c
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2008-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Show an average download speed in Download results.
|
||||
* src/BtFileAllocationEntry.cc
|
||||
* src/DefaultPieceStorage.cc
|
||||
* src/DownloadContext.cc
|
||||
* src/DownloadContext.h
|
||||
* src/DownloadResult.h
|
||||
* src/RequestGroup.cc
|
||||
* src/RequestGroupMan.cc
|
||||
* src/StreamFileAllocationEntry.cc
|
||||
|
||||
2008-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed the bug that metalink file is not processed if Content-Type
|
||||
|
|
|
@ -33,11 +33,14 @@
|
|||
*/
|
||||
/* copyright --> */
|
||||
#include "BtFileAllocationEntry.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "BtSetup.h"
|
||||
#include "RequestGroup.h"
|
||||
#include "Command.h"
|
||||
#include "DownloadEngine.h"
|
||||
#include <algorithm>
|
||||
#include "DownloadContext.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -51,6 +54,7 @@ void BtFileAllocationEntry::prepareForNextAction(std::deque<Command*>& commands,
|
|||
{
|
||||
BtSetup().setup(commands, _requestGroup, e, e->option);
|
||||
if(!_requestGroup->downloadFinished()) {
|
||||
_requestGroup->getDownloadContext()->resetDownloadStartTime();
|
||||
_requestGroup->createNextCommandWithAdj(commands, e, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -335,6 +335,7 @@ void DefaultPieceStorage::completePiece(const PieceHandle& piece)
|
|||
bitfieldMan->unsetUseBit(piece->getIndex());
|
||||
addPieceStats(piece->getIndex());
|
||||
if(downloadFinished()) {
|
||||
downloadContext->resetDownloadStopTime();
|
||||
diskAdaptor->onDownloadComplete();
|
||||
if(isSelectiveDownloadingMode()) {
|
||||
logger->notice(MSG_SELECTIVE_DOWNLOAD_COMPLETED);
|
||||
|
|
|
@ -36,7 +36,10 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
DownloadContext::DownloadContext():_dir(".") {}
|
||||
DownloadContext::DownloadContext():
|
||||
_dir("."),
|
||||
_downloadStartTime(0),
|
||||
_downloadStopTime(_downloadStartTime) {}
|
||||
|
||||
DownloadContext::~DownloadContext() {}
|
||||
|
||||
|
@ -60,4 +63,24 @@ void DownloadContext::setSignature(const SharedHandle<Signature>& signature)
|
|||
_signature = signature;
|
||||
}
|
||||
|
||||
void DownloadContext::resetDownloadStartTime()
|
||||
{
|
||||
_downloadStartTime.reset();
|
||||
}
|
||||
|
||||
void DownloadContext::resetDownloadStopTime()
|
||||
{
|
||||
_downloadStopTime.reset();
|
||||
}
|
||||
|
||||
int64_t DownloadContext::calculateSessionTime() const
|
||||
{
|
||||
if(_downloadStopTime.isNewer(_downloadStartTime)) {
|
||||
return
|
||||
_downloadStopTime.getTimeInMillis()-_downloadStartTime.getTimeInMillis();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -36,11 +36,14 @@
|
|||
#define _D_DOWNLOAD_CONTEXT_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "SharedHandle.h"
|
||||
#include "Signature.h"
|
||||
|
||||
#include <string>
|
||||
#include <deque>
|
||||
|
||||
#include "SharedHandle.h"
|
||||
#include "Signature.h"
|
||||
#include "TimeA2.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
class FileEntry;
|
||||
|
@ -51,8 +54,11 @@ protected:
|
|||
std::string _dir;
|
||||
|
||||
private:
|
||||
SharedHandle<Signature> _signature;
|
||||
Time _downloadStartTime;
|
||||
|
||||
Time _downloadStopTime;
|
||||
|
||||
SharedHandle<Signature> _signature;
|
||||
public:
|
||||
DownloadContext();
|
||||
|
||||
|
@ -98,6 +104,12 @@ public:
|
|||
SharedHandle<Signature> getSignature() const;
|
||||
|
||||
void setSignature(const SharedHandle<Signature>& signature);
|
||||
|
||||
void resetDownloadStartTime();
|
||||
|
||||
void resetDownloadStopTime();
|
||||
|
||||
int64_t calculateSessionTime() const;
|
||||
};
|
||||
|
||||
typedef SharedHandle<DownloadContext> DownloadContextHandle;
|
||||
|
|
|
@ -60,6 +60,10 @@ public:
|
|||
|
||||
size_t numUri;
|
||||
|
||||
uint64_t sessionDownloadLength;
|
||||
|
||||
int64_t sessionTime;
|
||||
|
||||
RESULT result;
|
||||
|
||||
DownloadResult(int32_t gid,
|
||||
|
@ -67,12 +71,16 @@ public:
|
|||
uint64_t totalLength,
|
||||
const std::string& uri,
|
||||
size_t numUri,
|
||||
uint64_t sessionDownloadLength,
|
||||
int64_t sessionTime,
|
||||
RESULT result):
|
||||
gid(gid),
|
||||
filePath(filePath),
|
||||
totalLength(totalLength),
|
||||
uri(uri),
|
||||
numUri(numUri),
|
||||
sessionDownloadLength(sessionDownloadLength),
|
||||
sessionTime(sessionTime),
|
||||
result(result) {}
|
||||
};
|
||||
|
||||
|
|
|
@ -877,15 +877,32 @@ DownloadResultHandle RequestGroup::createDownloadResult() const
|
|||
{
|
||||
std::deque<std::string> uris;
|
||||
getURIs(uris);
|
||||
|
||||
uint64_t sessionDownloadLength = 0;
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
if(!_peerStorage.isNull()) {
|
||||
sessionDownloadLength =
|
||||
_peerStorage->calculateStat().getSessionDownloadLength();
|
||||
} else
|
||||
#endif // ENABLE_BITTORRENT
|
||||
if(!_segmentMan.isNull()) {
|
||||
sessionDownloadLength =
|
||||
_segmentMan->calculateSessionDownloadLength();
|
||||
}
|
||||
|
||||
return
|
||||
SharedHandle<DownloadResult>(new DownloadResult(_gid,
|
||||
getFilePath(),
|
||||
getTotalLength(),
|
||||
uris.empty() ? A2STR::NIL:uris.front(),
|
||||
uris.size(),
|
||||
downloadFinished()?
|
||||
DownloadResult::FINISHED :
|
||||
DownloadResult::NOT_YET));
|
||||
SharedHandle<DownloadResult>
|
||||
(new DownloadResult(_gid,
|
||||
getFilePath(),
|
||||
getTotalLength(),
|
||||
uris.empty() ? A2STR::NIL:uris.front(),
|
||||
uris.size(),
|
||||
sessionDownloadLength,
|
||||
_downloadContext->calculateSessionTime(),
|
||||
downloadFinished()?
|
||||
DownloadResult::FINISHED :
|
||||
DownloadResult::NOT_YET));
|
||||
}
|
||||
|
||||
void RequestGroup::registerServerHost(const ServerHostHandle& serverHost)
|
||||
|
|
|
@ -33,6 +33,14 @@
|
|||
*/
|
||||
/* copyright --> */
|
||||
#include "RequestGroupMan.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <algorithm>
|
||||
|
||||
#include "BtProgressInfoFile.h"
|
||||
#include "RecoverableException.h"
|
||||
#include "RequestGroup.h"
|
||||
|
@ -52,12 +60,7 @@
|
|||
#include "Option.h"
|
||||
#include "prefs.h"
|
||||
#include "File.h"
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <algorithm>
|
||||
#include "Util.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -384,8 +387,8 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
// ===+====+=======================================================================
|
||||
o << "\n"
|
||||
<<_("Download Results:") << "\n"
|
||||
<< "gid|stat|path/URI" << "\n"
|
||||
<< "===+====+======================================================================" << "\n";
|
||||
<< "gid|stat|avg speed |path/URI" << "\n"
|
||||
<< "===+====+===========+==========================================================" << "\n";
|
||||
|
||||
int ok = 0;
|
||||
int err = 0;
|
||||
|
@ -411,6 +414,12 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const
|
|||
status = MARK_OK;
|
||||
++ok;
|
||||
} else {
|
||||
// Since this RequestGroup is not processed by ProcessStoppedRequestGroup,
|
||||
// its download stop time is not reseted.
|
||||
// Reset download stop time and assign sessionTime here.
|
||||
(*itr)->getDownloadContext()->resetDownloadStopTime();
|
||||
result->sessionTime =
|
||||
(*itr)->getDownloadContext()->calculateSessionTime();
|
||||
status = MARK_INPR;
|
||||
++inpr;
|
||||
}
|
||||
|
@ -437,7 +446,16 @@ std::string RequestGroupMan::formatDownloadResult(const std::string& status, con
|
|||
{
|
||||
std::stringstream o;
|
||||
o << std::setw(3) << downloadResult->gid << "|"
|
||||
<< std::setw(4) << status << "|";
|
||||
<< std::setw(4) << status << "|"
|
||||
<< std::setw(11);
|
||||
if(downloadResult->sessionTime > 0) {
|
||||
o << Util::abbrevSize
|
||||
(downloadResult->sessionDownloadLength*1000/downloadResult->sessionTime)+
|
||||
"B/s";
|
||||
} else {
|
||||
o << "n/a";
|
||||
}
|
||||
o << "|";
|
||||
if(downloadResult->result == DownloadResult::FINISHED) {
|
||||
o << downloadResult->filePath;
|
||||
} else {
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "prefs.h"
|
||||
#include "RequestGroup.h"
|
||||
#include "InitiateConnectionCommandFactory.h"
|
||||
#include "DownloadContext.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -57,6 +58,7 @@ StreamFileAllocationEntry::~StreamFileAllocationEntry() {}
|
|||
void StreamFileAllocationEntry::prepareForNextAction(std::deque<Command*>& commands,
|
||||
DownloadEngine* e)
|
||||
{
|
||||
_requestGroup->getDownloadContext()->resetDownloadStartTime();
|
||||
if(_nextCommand) {
|
||||
// give _nextCommand a chance to execute in the next execution loop.
|
||||
_nextCommand->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||
|
|
Loading…
Reference in New Issue