mirror of https://github.com/aria2/aria2
2007-06-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/FileAllocationCommand.cc: Derived from RealtimeCommand. * src/CheckIntegrityCommand.cc: Derived from RealtimeCommand. * src/MetalinkEntry.h (checksum): Changed to ChecksumHandle * src/MetalinkRequestInfo.cc (checksum): Changed to ChecksumHandle * src/File.cc (mkdirs): OPEN_MODE -> DIR_OPEN_MODE * src/common.h (DIR_OPEN_MODE): New definition * src/RequestGroup.cc (prepareForNextAction): Added an argument. * src/message.h (MSG_GOOD_CHECKSUM): New definition (MSG_BAD_CHECKSUM): New definition * src/HttpResponseCommand.cc (handleDefaultEncoding): Continue download sequence in new non-segmented download. * src/FileAllocationEntry.h (_nextDownloadCommand): New variable. * src/DownloadCommand.cc (prepareForNextSegment): Create ChecksumCommand if checksum is available. * src/RealtimeCommand.h, src/RealtimeCommand.cc: New class. * src/IteratableChecksumValidator.h, src/IteratableChecksumValidator.cc: New class. * src/ChecksumCommand.h, src/ChecksumCommand.cc: New class.pull/1/head
parent
8eeeac7192
commit
ccdd5b31a3
59
ChangeLog
59
ChangeLog
|
@ -1,3 +1,62 @@
|
||||||
|
2007-06-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
* src/FileAllocationCommand.cc: Derived from RealtimeCommand.
|
||||||
|
* src/CheckIntegrityCommand.cc: Derived from RealtimeCommand.
|
||||||
|
|
||||||
|
* src/MetalinkEntry.h
|
||||||
|
(checksum): Changed to ChecksumHandle
|
||||||
|
* src/MetalinkRequestInfo.cc
|
||||||
|
(checksum): Changed to ChecksumHandle
|
||||||
|
|
||||||
|
* src/File.cc
|
||||||
|
(mkdirs): OPEN_MODE -> DIR_OPEN_MODE
|
||||||
|
* src/common.h
|
||||||
|
(DIR_OPEN_MODE): New definition
|
||||||
|
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
(prepareForNextAction): Added an argument.
|
||||||
|
|
||||||
|
* src/message.h
|
||||||
|
(MSG_GOOD_CHECKSUM): New definition
|
||||||
|
(MSG_BAD_CHECKSUM): New definition
|
||||||
|
|
||||||
|
* src/HttpResponseCommand.cc
|
||||||
|
(handleDefaultEncoding): Continue download sequence in new
|
||||||
|
non-segmented download.
|
||||||
|
|
||||||
|
* src/FileAllocationEntry.h
|
||||||
|
(_nextDownloadCommand): New variable.
|
||||||
|
|
||||||
|
* src/DownloadCommand.cc
|
||||||
|
(prepareForNextSegment): Create ChecksumCommand if checksum is
|
||||||
|
available.
|
||||||
|
|
||||||
|
* src/RealtimeCommand.h, src/RealtimeCommand.cc: New class.
|
||||||
|
|
||||||
|
* src/IteratableChecksumValidator.h,
|
||||||
|
src/IteratableChecksumValidator.cc: New class.
|
||||||
|
|
||||||
|
* src/ChecksumCommand.h, src/ChecksumCommand.cc: New class.
|
||||||
|
|
||||||
|
2007-05-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Change file mode to 666:
|
||||||
|
* src/common.h (OPEN_MODE): New definition.
|
||||||
|
* src/File.cc
|
||||||
|
* src/Util.cc
|
||||||
|
* src/Directry.cc
|
||||||
|
* src/AbstractDiskWriter.cc
|
||||||
|
|
||||||
|
Change the level of log message "download aborted" to debug:
|
||||||
|
* src/PeerAbstractCommand.cc (execute)
|
||||||
|
|
||||||
|
* src/RequestGroup.h (RequestGroup): Initialized _hintTotalLength to 0.
|
||||||
|
|
||||||
|
* src/TrackerWatcherCommand.cc
|
||||||
|
(createCommand): Sleep some seconds after request failed.
|
||||||
|
If tracker request fails more than value of PREF_TRACKER_MAX_TRIES,
|
||||||
|
then abort tracker request.
|
||||||
|
|
||||||
2007-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2007-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
* Added the simultaneous download feature.
|
* Added the simultaneous download feature.
|
||||||
|
|
18
TODO
18
TODO
|
@ -22,18 +22,22 @@
|
||||||
* remove blockIndex
|
* remove blockIndex
|
||||||
* Add seed mode.
|
* Add seed mode.
|
||||||
|
|
||||||
* Add ChecksumCommand
|
* Rewrite ByteArrayDiskWriter, TrackerUpdateCommand with stringstream
|
||||||
|
* Make trakcerwatchercommand and trackerUploadCommand poses requestGroup
|
||||||
|
* consider life cycle of requestGroup and segmentMan
|
||||||
|
|
||||||
|
|
||||||
* Add fancy console read out. like this:
|
* Add fancy console read out. like this:
|
||||||
100K/300M(10%)(3cn)(3more) 100KB/s [FileAlloc:35MB/40MB(90%)][Checksum:10MB/20MB(50%)]
|
100K/300M(10%)(3cn)(3more) 100KB/s [FileAlloc:35MB/40MB(90%)][Checksum:10MB/20MB(50%)]
|
||||||
* exit status: all downloads have been successful-> EXIT_SUCCESS,
|
* exit status: all downloads have been successful-> EXIT_SUCCESS,
|
||||||
some of downloads have been failed -> EXIT_FAILURE
|
some of downloads have been failed -> EXIT_FAILURE
|
||||||
* consider life cycle of requestGroup and segmentMan
|
|
||||||
* use hintFilename and hintTotalLength if these are provided.
|
* use hintFilename and hintTotalLength if these are provided.
|
||||||
-> test against ftp downloads
|
-> test against ftp downloads
|
||||||
* make sure that the same file name is not used at the same time.
|
* make sure that the same file name is not used at the same time.
|
||||||
* Add a option like "line-feed-readout" which causes readout to be printed with proper line feed.
|
|
||||||
* Rewrite ByteArrayDiskWriter, TrackerUpdateCommand with stringstream
|
|
||||||
* Make trakcerwatchercommand and trackerUploadCommand poses requestGroup
|
|
||||||
* Do not use ufilename in multi-simultaneous download mode.
|
* Do not use ufilename in multi-simultaneous download mode.
|
||||||
* Merge umask patch.
|
* Replace numCommandToGenerate to the value of PREF_METALINK_SERVERS
|
||||||
https://sourceforge.net/tracker/index.php?func=detail&aid=1718641&group_id=159897&atid=813673
|
* Do not send range header if the position of starting byte is 0 and
|
||||||
|
the position of ending byte is not specified.
|
||||||
|
* Create download command directly when 1connection download.
|
||||||
|
Consider timeout when file allocation/check integrity is enabled.
|
||||||
|
* Test DefaultPeerStorage
|
|
@ -51,20 +51,23 @@ void CheckIntegrityCommand::initValidator()
|
||||||
_validator->init();
|
_validator->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckIntegrityCommand::execute()
|
bool CheckIntegrityCommand::executeInternal()
|
||||||
{
|
{
|
||||||
setStatusRealtime();
|
_validator->validateChunk();
|
||||||
_e->noWait = true;
|
if(_validator->finished()) {
|
||||||
|
if(_requestGroup->downloadFinished()) {
|
||||||
try {
|
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
|
||||||
_validator->validateChunk();
|
return true;
|
||||||
if(_validator->finished()) {
|
}
|
||||||
if(_requestGroup->downloadFinished()) {
|
if(_requestGroup->needsFileAllocation()) {
|
||||||
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
|
FileAllocationEntryHandle entry = new FileAllocationEntry(cuid, _req, _requestGroup);
|
||||||
return true;
|
entry->setNextDownloadCommand(_nextDownloadCommand);
|
||||||
}
|
_nextDownloadCommand = 0;
|
||||||
if(_requestGroup->needsFileAllocation()) {
|
_e->_fileAllocationMan->pushFileAllocationEntry(entry);
|
||||||
_e->_fileAllocationMan->pushFileAllocationEntry(new FileAllocationEntry(cuid, _req, _requestGroup));
|
} else {
|
||||||
|
if(_nextDownloadCommand) {
|
||||||
|
_e->commands.push_back(_nextDownloadCommand);
|
||||||
|
_nextDownloadCommand = 0;
|
||||||
} else {
|
} else {
|
||||||
int32_t numCommandsToGenerate = 15;
|
int32_t numCommandsToGenerate = 15;
|
||||||
Commands commands = _requestGroup->getNextCommand(_e, numCommandsToGenerate);
|
Commands commands = _requestGroup->getNextCommand(_e, numCommandsToGenerate);
|
||||||
|
@ -72,19 +75,23 @@ bool CheckIntegrityCommand::execute()
|
||||||
commands.push_front(command);
|
commands.push_front(command);
|
||||||
_e->addCommand(commands);
|
_e->addCommand(commands);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
_e->commands.push_back(this);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} catch(Exception* e) {
|
|
||||||
_requestGroup->getSegmentMan()->errors++;
|
|
||||||
logger->error("CUID#%d - Exception caught while validating file integrity.", e, cuid);
|
|
||||||
delete e;
|
|
||||||
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str());
|
|
||||||
// TODO this is wrong. There may exist invalid chunk data before catching
|
|
||||||
// exception. Fix this.
|
|
||||||
_requestGroup->markPieceDone(_validator->getCurrentOffset());
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
_e->commands.push_back(this);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckIntegrityCommand::handleException(Exception* e)
|
||||||
|
{
|
||||||
|
logger->error("CUID#%d - Exception caught while validating file integrity.", e, cuid);
|
||||||
|
delete e;
|
||||||
|
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str());
|
||||||
|
// TODO this is wrong. There may exist invalid chunk data before catching
|
||||||
|
// exception. Fix this.
|
||||||
|
// The one of the solution is having a copy of bitfield before settting its
|
||||||
|
// all bit to 1. If exception is thrown, then assign the copy to the bitfield.
|
||||||
|
_requestGroup->markPieceDone(_validator->getCurrentOffset());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -35,25 +35,22 @@
|
||||||
#ifndef _D_CHECK_INTEGRITY_COMMAND_H_
|
#ifndef _D_CHECK_INTEGRITY_COMMAND_H_
|
||||||
#define _D_CHECK_INTEGRITY_COMMAND_H_
|
#define _D_CHECK_INTEGRITY_COMMAND_H_
|
||||||
|
|
||||||
#include "Command.h"
|
#include "RealtimeCommand.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "RequestGroup.h"
|
|
||||||
#include "DownloadEngine.h"
|
|
||||||
#include "IteratableChunkChecksumValidator.h"
|
#include "IteratableChunkChecksumValidator.h"
|
||||||
|
#include "DownloadCommand.h"
|
||||||
|
|
||||||
class CheckIntegrityCommand : public Command {
|
class CheckIntegrityCommand : public RealtimeCommand {
|
||||||
private:
|
private:
|
||||||
RequestHandle _req;
|
RequestHandle _req;
|
||||||
RequestGroup* _requestGroup;
|
|
||||||
DownloadEngine* _e;
|
|
||||||
IteratableChunkChecksumValidatorHandle _validator;
|
IteratableChunkChecksumValidatorHandle _validator;
|
||||||
|
DownloadCommand* _nextDownloadCommand;
|
||||||
public:
|
public:
|
||||||
CheckIntegrityCommand(int cuid, const RequestHandle& req, RequestGroup* requestGroup, DownloadEngine* e):
|
CheckIntegrityCommand(int cuid, const RequestHandle& req, RequestGroup* requestGroup, DownloadEngine* e):
|
||||||
Command(cuid),
|
RealtimeCommand(cuid, requestGroup, e),
|
||||||
_req(req),
|
_req(req),
|
||||||
_requestGroup(requestGroup),
|
_validator(0),
|
||||||
_e(e),
|
_nextDownloadCommand(0)
|
||||||
_validator(0)
|
|
||||||
{
|
{
|
||||||
++_requestGroup->numConnection;
|
++_requestGroup->numConnection;
|
||||||
}
|
}
|
||||||
|
@ -61,11 +58,19 @@ public:
|
||||||
virtual ~CheckIntegrityCommand()
|
virtual ~CheckIntegrityCommand()
|
||||||
{
|
{
|
||||||
--_requestGroup->numConnection;
|
--_requestGroup->numConnection;
|
||||||
|
delete _nextDownloadCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initValidator();
|
void initValidator();
|
||||||
|
|
||||||
virtual bool execute();
|
virtual bool executeInternal();
|
||||||
|
|
||||||
|
virtual bool handleException(Exception* e);
|
||||||
|
|
||||||
|
void setNextDownloadCommand(DownloadCommand* command)
|
||||||
|
{
|
||||||
|
_nextDownloadCommand = command;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _D_CHECK_INTEGRITY_COMMAND_H_
|
#endif // _D_CHECK_INTEGRITY_COMMAND_H_
|
||||||
|
|
|
@ -74,4 +74,6 @@ class Checksum {
|
||||||
};
|
};
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
|
||||||
|
typedef SharedHandle<Checksum> ChecksumHandle;
|
||||||
|
|
||||||
#endif // _D_CHECKSUM_H_
|
#endif // _D_CHECKSUM_H_
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#include "ChecksumCommand.h"
|
||||||
|
#include "DlAbortEx.h"
|
||||||
|
#include "message.h"
|
||||||
|
|
||||||
|
void ChecksumCommand::initValidator()
|
||||||
|
{
|
||||||
|
_validator = new IteratableChecksumValidator();
|
||||||
|
_validator->setChecksum(_requestGroup->getChecksum());
|
||||||
|
_validator->setDiskWriter(_requestGroup->getSegmentMan()->diskWriter);
|
||||||
|
_validator->setBitfield(_requestGroup->getSegmentMan()->getBitfield());
|
||||||
|
if(!_validator->canValidate()) {
|
||||||
|
// insufficient checksums.
|
||||||
|
throw new DlAbortEx("Insufficient checksums.");
|
||||||
|
}
|
||||||
|
_validator->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChecksumCommand::executeInternal()
|
||||||
|
{
|
||||||
|
_validator->validateChunk();
|
||||||
|
if(_validator->finished()) {
|
||||||
|
if(_requestGroup->downloadFinished()) {
|
||||||
|
logger->notice(MSG_GOOD_CHECKSUM, cuid, _requestGroup->getFilePath().c_str());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
logger->error(MSG_BAD_CHECKSUM, cuid, _requestGroup->getFilePath().c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_e->commands.push_back(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChecksumCommand::handleException(Exception* e)
|
||||||
|
{
|
||||||
|
logger->error("CUID#%d - Exception caught while validating file integrity.", e, cuid);
|
||||||
|
delete e;
|
||||||
|
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str());
|
||||||
|
// TODO We need to set bitfield back to the state when validation begun.
|
||||||
|
// The one of the solution is having a copy of bitfield before settting its
|
||||||
|
// all bit to 1. If exception is thrown, then assign the copy to the bitfield.
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#ifndef _D_CHECKSUM_COMMAND_H_
|
||||||
|
#define _D_CHECKSUM_COMMAND_H_
|
||||||
|
|
||||||
|
#include "RealtimeCommand.h"
|
||||||
|
#include "IteratableChecksumValidator.h"
|
||||||
|
|
||||||
|
class ChecksumCommand : public RealtimeCommand
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
IteratableChecksumValidatorHandle _validator;
|
||||||
|
public:
|
||||||
|
ChecksumCommand(int cuid, RequestGroup* requestGroup, DownloadEngine* e):
|
||||||
|
RealtimeCommand(cuid, requestGroup, e),
|
||||||
|
_validator(0)
|
||||||
|
{
|
||||||
|
++_requestGroup->numConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~ChecksumCommand()
|
||||||
|
{
|
||||||
|
--_requestGroup->numConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initValidator();
|
||||||
|
|
||||||
|
virtual bool executeInternal();
|
||||||
|
|
||||||
|
virtual bool handleException(Exception* e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _D_CHECKSUM_COMMAND_H_
|
|
@ -49,7 +49,7 @@ void ChunkChecksumValidator::validateSameLengthChecksum(BitfieldMan* bitfieldMan
|
||||||
string actualChecksum = diskWriter->messageDigest(offset, dataLength, algo);
|
string actualChecksum = diskWriter->messageDigest(offset, dataLength, algo);
|
||||||
if(actualChecksum != expectedChecksum) {
|
if(actualChecksum != expectedChecksum) {
|
||||||
logger->info(EX_INVALID_CHUNK_CHECKSUM,
|
logger->info(EX_INVALID_CHUNK_CHECKSUM,
|
||||||
index, offset, dataLength,
|
index, offset,
|
||||||
expectedChecksum.c_str(), actualChecksum.c_str());
|
expectedChecksum.c_str(), actualChecksum.c_str());
|
||||||
bitfieldMan->unsetBit(index);
|
bitfieldMan->unsetBit(index);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ void ChunkChecksumValidator::validateDifferentLengthChecksum(BitfieldMan* bitfie
|
||||||
if(expectedChecksum != actualChecksum) {
|
if(expectedChecksum != actualChecksum) {
|
||||||
// wrong checksum
|
// wrong checksum
|
||||||
logger->info(EX_INVALID_CHUNK_CHECKSUM,
|
logger->info(EX_INVALID_CHUNK_CHECKSUM,
|
||||||
index, offset, dataLength,
|
index, offset,
|
||||||
expectedChecksum.c_str(), actualChecksum.c_str());
|
expectedChecksum.c_str(), actualChecksum.c_str());
|
||||||
bitfieldMan->unsetBitRange(startIndex, endIndex);
|
bitfieldMan->unsetBitRange(startIndex, endIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,18 +35,3 @@
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
int Command::uuidGen = 0;
|
int Command::uuidGen = 0;
|
||||||
|
|
||||||
bool Command::statusMatch(Command::STATUS statusFilter) const
|
|
||||||
{
|
|
||||||
return statusFilter <= status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Command::transitStatus()
|
|
||||||
{
|
|
||||||
switch(status) {
|
|
||||||
case STATUS_REALTIME:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
status = STATUS_INACTIVE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -71,9 +71,20 @@ public:
|
||||||
|
|
||||||
void setStatusRealtime() { this->status = STATUS_REALTIME; }
|
void setStatusRealtime() { this->status = STATUS_REALTIME; }
|
||||||
|
|
||||||
void transitStatus();
|
bool statusMatch(Command::STATUS statusFilter) const
|
||||||
|
{
|
||||||
|
return statusFilter <= status;
|
||||||
|
}
|
||||||
|
|
||||||
bool statusMatch(Command::STATUS statusFilter) const;
|
void transitStatus()
|
||||||
|
{
|
||||||
|
switch(status) {
|
||||||
|
case STATUS_REALTIME:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
status = STATUS_INACTIVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef deque<Command*> Commands;
|
typedef deque<Command*> Commands;
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "InitiateConnectionCommandFactory.h"
|
#include "InitiateConnectionCommandFactory.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "prefs.h"
|
#include "prefs.h"
|
||||||
|
#include "ChecksumCommand.h"
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
DownloadCommand::DownloadCommand(int cuid,
|
DownloadCommand::DownloadCommand(int cuid,
|
||||||
|
@ -125,6 +126,11 @@ bool DownloadCommand::executeInternal() {
|
||||||
|
|
||||||
bool DownloadCommand::prepareForNextSegment() {
|
bool DownloadCommand::prepareForNextSegment() {
|
||||||
if(_requestGroup->getSegmentMan()->finished()) {
|
if(_requestGroup->getSegmentMan()->finished()) {
|
||||||
|
if(!_requestGroup->getChecksum().isNull() &&
|
||||||
|
!_requestGroup->getChecksum()->isEmpty()) {
|
||||||
|
ChecksumCommand* command = new ChecksumCommand(cuid, _requestGroup, e);
|
||||||
|
e->commands.push_back(command);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Merge segment with next segment, if segment.index+1 == nextSegment.index
|
// Merge segment with next segment, if segment.index+1 == nextSegment.index
|
||||||
|
|
|
@ -94,6 +94,7 @@ bool File::mkdirs() {
|
||||||
if(!dirs.size()) {
|
if(!dirs.size()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string accDir;
|
string accDir;
|
||||||
if(Util::startsWith(name, "/")) {
|
if(Util::startsWith(name, "/")) {
|
||||||
accDir = "/";
|
accDir = "/";
|
||||||
|
@ -104,7 +105,7 @@ bool File::mkdirs() {
|
||||||
if(File(accDir).isDir()) {
|
if(File(accDir).isDir()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(mkdir(accDir.c_str(), OPEN_MODE) == -1) {
|
if(mkdir(accDir.c_str(), DIR_OPEN_MODE) == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,21 +35,23 @@
|
||||||
#include "FileAllocationCommand.h"
|
#include "FileAllocationCommand.h"
|
||||||
#include "InitiateConnectionCommandFactory.h"
|
#include "InitiateConnectionCommandFactory.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
|
#include "DownloadCommand.h"
|
||||||
|
|
||||||
bool FileAllocationCommand::execute()
|
bool FileAllocationCommand::executeInternal()
|
||||||
{
|
{
|
||||||
setStatusRealtime();
|
_fileAllocationEntry->allocateChunk();
|
||||||
_e->noWait = true;
|
|
||||||
try {
|
|
||||||
_fileAllocationEntry->allocateChunk();
|
|
||||||
|
|
||||||
if(_fileAllocationEntry->allocationFinished()) {
|
if(_fileAllocationEntry->allocationFinished()) {
|
||||||
int64_t totalLength = _requestGroup->getSegmentMan()->totalSize;
|
int64_t totalLength = _requestGroup->getSegmentMan()->totalSize;
|
||||||
logger->debug("%d seconds to allocate %lld byte(s)",
|
logger->debug("%d seconds to allocate %lld byte(s)",
|
||||||
_timer.difference(), totalLength);
|
_timer.difference(), totalLength);
|
||||||
|
|
||||||
_e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
|
_e->_fileAllocationMan->markCurrentFileAllocationEntryDone();
|
||||||
|
|
||||||
|
if(_fileAllocationEntry->getNextDownloadCommand()) {
|
||||||
|
_e->commands.push_back(_fileAllocationEntry->getNextDownloadCommand());
|
||||||
|
_fileAllocationEntry->setNextDownloadCommand(0);
|
||||||
|
} else {
|
||||||
int32_t numCommandsToGenerate = 15;
|
int32_t numCommandsToGenerate = 15;
|
||||||
Commands commands = _requestGroup->getNextCommand(_e, numCommandsToGenerate);
|
Commands commands = _requestGroup->getNextCommand(_e, numCommandsToGenerate);
|
||||||
|
|
||||||
|
@ -58,16 +60,18 @@ bool FileAllocationCommand::execute()
|
||||||
commands.push_front(command);
|
commands.push_front(command);
|
||||||
|
|
||||||
_e->addCommand(commands);
|
_e->addCommand(commands);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
_e->commands.push_back(this);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} catch(Exception* e) {
|
|
||||||
_requestGroup->getSegmentMan()->errors++;
|
|
||||||
logger->error("CUID#%d - Exception caught while allocating file space.", e, cuid);
|
|
||||||
delete e;
|
|
||||||
logger->notice(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str());
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
_e->commands.push_back(this);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileAllocationCommand::handleException(Exception* e)
|
||||||
|
{
|
||||||
|
logger->error("CUID#%d - Exception caught while allocating file space.", e, cuid);
|
||||||
|
delete e;
|
||||||
|
logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, _requestGroup->getFilePath().c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -35,29 +35,25 @@
|
||||||
#ifndef _D_FILE_ALLOCATION_COMMAND_H_
|
#ifndef _D_FILE_ALLOCATION_COMMAND_H_
|
||||||
#define _D_FILE_ALLOCATION_COMMAND_H_
|
#define _D_FILE_ALLOCATION_COMMAND_H_
|
||||||
|
|
||||||
#include "Command.h"
|
#include "RealtimeCommand.h"
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "RequestGroup.h"
|
|
||||||
#include "DownloadEngine.h"
|
|
||||||
#include "TimeA2.h"
|
#include "TimeA2.h"
|
||||||
#include "FileAllocationEntry.h"
|
#include "FileAllocationEntry.h"
|
||||||
|
|
||||||
class FileAllocationCommand : public Command {
|
class FileAllocationCommand : public RealtimeCommand {
|
||||||
private:
|
private:
|
||||||
RequestHandle _req;
|
RequestHandle _req;
|
||||||
RequestGroup* _requestGroup;
|
|
||||||
DownloadEngine* _e;
|
|
||||||
FileAllocationEntryHandle _fileAllocationEntry;
|
FileAllocationEntryHandle _fileAllocationEntry;
|
||||||
Time _timer;
|
Time _timer;
|
||||||
public:
|
public:
|
||||||
FileAllocationCommand(int cuid, const RequestHandle& req, RequestGroup* requestGroup, DownloadEngine* e, const FileAllocationEntryHandle& fileAllocationEntry):
|
FileAllocationCommand(int cuid, const RequestHandle& req, RequestGroup* requestGroup, DownloadEngine* e, const FileAllocationEntryHandle& fileAllocationEntry):
|
||||||
Command(cuid),
|
RealtimeCommand(cuid, requestGroup, e),
|
||||||
_req(req),
|
_req(req),
|
||||||
_requestGroup(requestGroup),
|
|
||||||
_e(e),
|
|
||||||
_fileAllocationEntry(fileAllocationEntry) {}
|
_fileAllocationEntry(fileAllocationEntry) {}
|
||||||
|
|
||||||
virtual bool execute();
|
virtual bool executeInternal();
|
||||||
|
|
||||||
|
virtual bool handleException(Exception* e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _D_FILE_ALLOCATION_COMMAND_H_
|
#endif // _D_FILE_ALLOCATION_COMMAND_H_
|
||||||
|
|
|
@ -33,9 +33,16 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "FileAllocationEntry.h"
|
#include "FileAllocationEntry.h"
|
||||||
|
#include "DownloadCommand.h"
|
||||||
|
|
||||||
#define BUFSIZE 16*1024
|
#define BUFSIZE 16*1024
|
||||||
|
|
||||||
|
FileAllocationEntry::~FileAllocationEntry()
|
||||||
|
{
|
||||||
|
--_requestGroup->numConnection;
|
||||||
|
delete _nextDownloadCommand;
|
||||||
|
}
|
||||||
|
|
||||||
void FileAllocationEntry::allocateChunk()
|
void FileAllocationEntry::allocateChunk()
|
||||||
{
|
{
|
||||||
int32_t bufSize = BUFSIZE;
|
int32_t bufSize = BUFSIZE;
|
||||||
|
|
|
@ -39,12 +39,15 @@
|
||||||
#include "Request.h"
|
#include "Request.h"
|
||||||
#include "RequestGroup.h"
|
#include "RequestGroup.h"
|
||||||
|
|
||||||
|
class DownloadCommand;
|
||||||
|
|
||||||
class FileAllocationEntry {
|
class FileAllocationEntry {
|
||||||
private:
|
private:
|
||||||
int _cuid;
|
int _cuid;
|
||||||
RequestHandle _currentRequest;
|
RequestHandle _currentRequest;
|
||||||
RequestGroup* _requestGroup;
|
RequestGroup* _requestGroup;
|
||||||
int64_t _offset;
|
int64_t _offset;
|
||||||
|
DownloadCommand* _nextDownloadCommand;
|
||||||
public:
|
public:
|
||||||
FileAllocationEntry(int cuid,
|
FileAllocationEntry(int cuid,
|
||||||
const RequestHandle& currentRequest,
|
const RequestHandle& currentRequest,
|
||||||
|
@ -53,15 +56,13 @@ public:
|
||||||
_cuid(cuid),
|
_cuid(cuid),
|
||||||
_currentRequest(currentRequest),
|
_currentRequest(currentRequest),
|
||||||
_requestGroup(requestGroup),
|
_requestGroup(requestGroup),
|
||||||
_offset(offset)
|
_offset(offset),
|
||||||
|
_nextDownloadCommand(0)
|
||||||
{
|
{
|
||||||
++_requestGroup->numConnection;
|
++_requestGroup->numConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileAllocationEntry()
|
~FileAllocationEntry();
|
||||||
{
|
|
||||||
--_requestGroup->numConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getCUID() const
|
int getCUID() const
|
||||||
{
|
{
|
||||||
|
@ -94,6 +95,16 @@ public:
|
||||||
{
|
{
|
||||||
return _requestGroup->getSegmentMan()->totalSize <= _offset;
|
return _requestGroup->getSegmentMan()->totalSize <= _offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setNextDownloadCommand(DownloadCommand* command)
|
||||||
|
{
|
||||||
|
_nextDownloadCommand = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
DownloadCommand* getNextDownloadCommand() const
|
||||||
|
{
|
||||||
|
return _nextDownloadCommand;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<FileAllocationEntry> FileAllocationEntryHandle;
|
typedef SharedHandle<FileAllocationEntry> FileAllocationEntryHandle;
|
||||||
|
|
|
@ -47,9 +47,7 @@ HttpDownloadCommand::HttpDownloadCommand(int cuid,
|
||||||
HttpDownloadCommand::~HttpDownloadCommand() {}
|
HttpDownloadCommand::~HttpDownloadCommand() {}
|
||||||
|
|
||||||
bool HttpDownloadCommand::prepareForNextSegment() {
|
bool HttpDownloadCommand::prepareForNextSegment() {
|
||||||
if(_requestGroup->getSegmentMan()->finished()) {
|
if(!_requestGroup->getSegmentMan()->finished()) {
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if(req->isKeepAlive()) {
|
if(req->isKeepAlive()) {
|
||||||
Command* command = new HttpRequestCommand(cuid, req, _requestGroup, e, socket);
|
Command* command = new HttpRequestCommand(cuid, req, _requestGroup, e, socket);
|
||||||
e->commands.push_back(command);
|
e->commands.push_back(command);
|
||||||
|
@ -57,5 +55,7 @@ bool HttpDownloadCommand::prepareForNextSegment() {
|
||||||
} else {
|
} else {
|
||||||
return DownloadCommand::prepareForNextSegment();
|
return DownloadCommand::prepareForNextSegment();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return DownloadCommand::prepareForNextSegment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ bool HttpResponseCommand::executeInternal()
|
||||||
_requestGroup->validateFilename(httpResponse->determinFilename());
|
_requestGroup->validateFilename(httpResponse->determinFilename());
|
||||||
_requestGroup->validateTotalLength(httpResponse->getEntityLength());
|
_requestGroup->validateTotalLength(httpResponse->getEntityLength());
|
||||||
|
|
||||||
createHttpDownloadCommand(httpResponse);
|
e->commands.push_back(createHttpDownloadCommand(httpResponse));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// TODO validate totalsize against hintTotalSize if it is provided.
|
// TODO validate totalsize against hintTotalSize if it is provided.
|
||||||
|
@ -136,8 +136,13 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DownloadCommand* command = 0;
|
||||||
|
File file(_requestGroup->getFilePath());
|
||||||
|
if(_requestGroup->getRemainingUris().empty() && !file.exists()) {
|
||||||
|
command = createHttpDownloadCommand(httpResponse);
|
||||||
|
}
|
||||||
_requestGroup->loadAndOpenFile();
|
_requestGroup->loadAndOpenFile();
|
||||||
_requestGroup->prepareForNextAction(cuid, req, e);
|
_requestGroup->prepareForNextAction(cuid, req, e, command);
|
||||||
e->noWait = true;
|
e->noWait = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -157,11 +162,11 @@ bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResp
|
||||||
req->setKeepAlive(false);
|
req->setKeepAlive(false);
|
||||||
segment = _requestGroup->getSegmentMan()->getSegment(cuid);
|
segment = _requestGroup->getSegmentMan()->getSegment(cuid);
|
||||||
_requestGroup->getSegmentMan()->diskWriter->initAndOpenFile(_requestGroup->getSegmentMan()->getFilePath());
|
_requestGroup->getSegmentMan()->diskWriter->initAndOpenFile(_requestGroup->getSegmentMan()->getFilePath());
|
||||||
createHttpDownloadCommand(httpResponse);
|
e->commands.push_back(createHttpDownloadCommand(httpResponse));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpResponseCommand::createHttpDownloadCommand(const HttpResponseHandle& httpResponse)
|
HttpDownloadCommand* HttpResponseCommand::createHttpDownloadCommand(const HttpResponseHandle& httpResponse)
|
||||||
{
|
{
|
||||||
TransferEncodingHandle enc = 0;
|
TransferEncodingHandle enc = 0;
|
||||||
if(httpResponse->isTransferEncodingSpecified()) {
|
if(httpResponse->isTransferEncodingSpecified()) {
|
||||||
|
@ -179,7 +184,7 @@ void HttpResponseCommand::createHttpDownloadCommand(const HttpResponseHandle& ht
|
||||||
command->setLowestDownloadSpeedLimit(e->option->getAsInt(PREF_LOWEST_SPEED_LIMIT));
|
command->setLowestDownloadSpeedLimit(e->option->getAsInt(PREF_LOWEST_SPEED_LIMIT));
|
||||||
command->setTransferDecoder(enc);
|
command->setTransferDecoder(enc);
|
||||||
|
|
||||||
e->commands.push_back(command);
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HttpResponseCommand::doTorrentStuff(const HttpResponseHandle& httpResponse)
|
bool HttpResponseCommand::doTorrentStuff(const HttpResponseHandle& httpResponse)
|
||||||
|
@ -195,6 +200,6 @@ bool HttpResponseCommand::doTorrentStuff(const HttpResponseHandle& httpResponse)
|
||||||
_requestGroup->getSegmentMan()->isSplittable = false;
|
_requestGroup->getSegmentMan()->isSplittable = false;
|
||||||
_requestGroup->getSegmentMan()->downloadStarted = true;
|
_requestGroup->getSegmentMan()->downloadStarted = true;
|
||||||
_requestGroup->getSegmentMan()->diskWriter->initAndOpenFile("/tmp/aria2"+Util::itos((int32_t)getpid()));
|
_requestGroup->getSegmentMan()->diskWriter->initAndOpenFile("/tmp/aria2"+Util::itos((int32_t)getpid()));
|
||||||
createHttpDownloadCommand(httpResponse);
|
e->commands.push_back(createHttpDownloadCommand(httpResponse));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "AbstractCommand.h"
|
#include "AbstractCommand.h"
|
||||||
#include "HttpConnection.h"
|
#include "HttpConnection.h"
|
||||||
|
#include "HttpDownloadCommand.h"
|
||||||
|
|
||||||
class HttpResponseCommand : public AbstractCommand {
|
class HttpResponseCommand : public AbstractCommand {
|
||||||
private:
|
private:
|
||||||
|
@ -44,7 +45,7 @@ private:
|
||||||
|
|
||||||
bool handleDefaultEncoding(const HttpResponseHandle& httpResponse);
|
bool handleDefaultEncoding(const HttpResponseHandle& httpResponse);
|
||||||
bool handleOtherEncoding(const HttpResponseHandle& httpResponse);
|
bool handleOtherEncoding(const HttpResponseHandle& httpResponse);
|
||||||
void createHttpDownloadCommand(const HttpResponseHandle& httpResponse);
|
HttpDownloadCommand* createHttpDownloadCommand(const HttpResponseHandle& httpResponse);
|
||||||
bool doTorrentStuff(const HttpResponseHandle& httpResponse);
|
bool doTorrentStuff(const HttpResponseHandle& httpResponse);
|
||||||
protected:
|
protected:
|
||||||
bool executeInternal();
|
bool executeInternal();
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#include "IteratableChecksumValidator.h"
|
||||||
|
#include "Util.h"
|
||||||
|
#include "message.h"
|
||||||
|
|
||||||
|
#define BUFSIZE 16*1024
|
||||||
|
|
||||||
|
void IteratableChecksumValidator::validateChunk()
|
||||||
|
{
|
||||||
|
if(!finished()) {
|
||||||
|
|
||||||
|
char data[BUFSIZE];
|
||||||
|
|
||||||
|
int32_t size = _diskWriter->readData(data, sizeof(data), _currentOffset);
|
||||||
|
|
||||||
|
_ctx->digestUpdate(data, size);
|
||||||
|
_currentOffset += sizeof(data);
|
||||||
|
|
||||||
|
if(finished()) {
|
||||||
|
unsigned char* digest = new unsigned char[_ctx->digestLength()];
|
||||||
|
try {
|
||||||
|
_ctx->digestFinal(digest);
|
||||||
|
if(_checksum->getMessageDigest() != Util::toHex(digest, _ctx->digestLength())) {
|
||||||
|
_bitfield->clearAllBit();
|
||||||
|
}
|
||||||
|
delete [] digest;
|
||||||
|
} catch(...) {
|
||||||
|
delete [] digest;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IteratableChecksumValidator::canValidate() const
|
||||||
|
{
|
||||||
|
// We assume file is already opened using DiskWriter::open or openExistingFile.
|
||||||
|
return !_checksum.isNull() && !_checksum->isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IteratableChecksumValidator::init()
|
||||||
|
{
|
||||||
|
_bitfield->setAllBit();
|
||||||
|
_currentOffset = 0;
|
||||||
|
|
||||||
|
_ctx = new MessageDigestContext(_checksum->getDigestAlgo());
|
||||||
|
_ctx->digestInit();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#ifndef _D_ITERATABLE_CHECKSUM_VALIDATOR_H_
|
||||||
|
#define _D_ITERATABLE_CHECKSUM_VALIDATOR_H_
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "BitfieldMan.h"
|
||||||
|
#include "Checksum.h"
|
||||||
|
#include "DiskWriter.h"
|
||||||
|
#include "LogFactory.h"
|
||||||
|
#include "messageDigest.h"
|
||||||
|
|
||||||
|
class IteratableChecksumValidator
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
DiskWriterHandle _diskWriter;
|
||||||
|
BitfieldMan* _bitfield;
|
||||||
|
int64_t _currentOffset;
|
||||||
|
ChecksumHandle _checksum;
|
||||||
|
const Logger* logger;
|
||||||
|
MessageDigestContextHandle _ctx;
|
||||||
|
|
||||||
|
string calculateActualChecksum();
|
||||||
|
public:
|
||||||
|
IteratableChecksumValidator():_diskWriter(0), _bitfield(0), _currentOffset(0), _checksum(0), logger(LogFactory::getInstance()), _ctx(0) {}
|
||||||
|
|
||||||
|
bool canValidate() const;
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
void validateChunk();
|
||||||
|
|
||||||
|
bool finished() const
|
||||||
|
{
|
||||||
|
return _currentOffset >= _bitfield->getTotalLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDiskWriter(const DiskWriterHandle& diskWriter)
|
||||||
|
{
|
||||||
|
_diskWriter = diskWriter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBitfield(BitfieldMan* bitfield)
|
||||||
|
{
|
||||||
|
_bitfield = bitfield;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setChecksum(const ChecksumHandle& checksum)
|
||||||
|
{
|
||||||
|
_checksum = checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t getCurrentOffset() const
|
||||||
|
{
|
||||||
|
return _currentOffset;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef SharedHandle<IteratableChecksumValidator> IteratableChecksumValidatorHandle;
|
||||||
|
|
||||||
|
#endif // _D_ITERATABLE_CHECKSUM_VALIDATOR_H_
|
|
@ -95,7 +95,10 @@ SRCS = Socket.h\
|
||||||
UriFileListParser.cc UriFileListParser.h\
|
UriFileListParser.cc UriFileListParser.h\
|
||||||
SegmentManFactory.h\
|
SegmentManFactory.h\
|
||||||
AbstractSegmentManFactory.h\
|
AbstractSegmentManFactory.h\
|
||||||
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h
|
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h\
|
||||||
|
RealtimeCommand.cc RealtimeCommand.h\
|
||||||
|
IteratableChecksumValidator.cc IteratableChecksumValidator.h\
|
||||||
|
ChecksumCommand.cc ChecksumCommand.h
|
||||||
# debug_new.cpp
|
# debug_new.cpp
|
||||||
|
|
||||||
if ENABLE_BITTORRENT
|
if ENABLE_BITTORRENT
|
||||||
|
@ -220,9 +223,9 @@ libaria2c_a_SOURCES = $(SRCS)
|
||||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||||
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
||||||
@LIBCARES_LIBS@
|
@LIBCARES_LIBS@
|
||||||
#aria2c_LDFLAGS = -pg
|
aria2c_LDFLAGS = -pg
|
||||||
AM_CPPFLAGS = -Wall\
|
AM_CPPFLAGS = -Wall\
|
||||||
-I../lib -I../intl -I$(top_srcdir)/intl\
|
-I../lib -I../intl -I$(top_srcdir)/intl\
|
||||||
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
||||||
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
||||||
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@# -pg
|
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@ -pg
|
|
@ -237,8 +237,11 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
|
||||||
MultiUrlRequestInfo.h UriFileListParser.cc UriFileListParser.h \
|
MultiUrlRequestInfo.h UriFileListParser.cc UriFileListParser.h \
|
||||||
SegmentManFactory.h AbstractSegmentManFactory.h \
|
SegmentManFactory.h AbstractSegmentManFactory.h \
|
||||||
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h \
|
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h \
|
||||||
MetaEntry.h Data.cc Data.h Dictionary.cc Dictionary.h List.cc \
|
RealtimeCommand.cc RealtimeCommand.h \
|
||||||
List.h MetaFileUtil.cc MetaFileUtil.h MetaEntryVisitor.h \
|
IteratableChecksumValidator.cc IteratableChecksumValidator.h \
|
||||||
|
ChecksumCommand.cc ChecksumCommand.h MetaEntry.h Data.cc \
|
||||||
|
Data.h Dictionary.cc Dictionary.h List.cc List.h \
|
||||||
|
MetaFileUtil.cc MetaFileUtil.h MetaEntryVisitor.h \
|
||||||
ShaVisitor.cc ShaVisitor.h PeerConnection.cc PeerConnection.h \
|
ShaVisitor.cc ShaVisitor.h PeerConnection.cc PeerConnection.h \
|
||||||
PeerMessageUtil.cc PeerMessageUtil.h PeerAbstractCommand.cc \
|
PeerMessageUtil.cc PeerMessageUtil.h PeerAbstractCommand.cc \
|
||||||
PeerAbstractCommand.h PeerInitiateConnectionCommand.cc \
|
PeerAbstractCommand.h PeerInitiateConnectionCommand.cc \
|
||||||
|
@ -419,8 +422,9 @@ am__objects_3 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
|
||||||
IteratableChunkChecksumValidator.$(OBJEXT) \
|
IteratableChunkChecksumValidator.$(OBJEXT) \
|
||||||
CheckIntegrityCommand.$(OBJEXT) SingleUrlRequestInfo.$(OBJEXT) \
|
CheckIntegrityCommand.$(OBJEXT) SingleUrlRequestInfo.$(OBJEXT) \
|
||||||
MultiUrlRequestInfo.$(OBJEXT) UriFileListParser.$(OBJEXT) \
|
MultiUrlRequestInfo.$(OBJEXT) UriFileListParser.$(OBJEXT) \
|
||||||
DefaultSegmentManFactory.$(OBJEXT) $(am__objects_1) \
|
DefaultSegmentManFactory.$(OBJEXT) RealtimeCommand.$(OBJEXT) \
|
||||||
$(am__objects_2)
|
IteratableChecksumValidator.$(OBJEXT) \
|
||||||
|
ChecksumCommand.$(OBJEXT) $(am__objects_1) $(am__objects_2)
|
||||||
am_libaria2c_a_OBJECTS = $(am__objects_3)
|
am_libaria2c_a_OBJECTS = $(am__objects_3)
|
||||||
libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
|
libaria2c_a_OBJECTS = $(am_libaria2c_a_OBJECTS)
|
||||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||||
|
@ -649,19 +653,22 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
|
||||||
MultiUrlRequestInfo.h UriFileListParser.cc UriFileListParser.h \
|
MultiUrlRequestInfo.h UriFileListParser.cc UriFileListParser.h \
|
||||||
SegmentManFactory.h AbstractSegmentManFactory.h \
|
SegmentManFactory.h AbstractSegmentManFactory.h \
|
||||||
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h \
|
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h \
|
||||||
$(am__append_1) $(am__append_2)
|
RealtimeCommand.cc RealtimeCommand.h \
|
||||||
|
IteratableChecksumValidator.cc IteratableChecksumValidator.h \
|
||||||
|
ChecksumCommand.cc ChecksumCommand.h $(am__append_1) \
|
||||||
|
$(am__append_2)
|
||||||
noinst_LIBRARIES = libaria2c.a
|
noinst_LIBRARIES = libaria2c.a
|
||||||
libaria2c_a_SOURCES = $(SRCS)
|
libaria2c_a_SOURCES = $(SRCS)
|
||||||
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
|
||||||
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
@LIBGCRYPT_LIBS@ @OPENSSL_LIBS@ @XML_LIBS@ @LIBARES_LIBS@\
|
||||||
@LIBCARES_LIBS@
|
@LIBCARES_LIBS@
|
||||||
|
|
||||||
#aria2c_LDFLAGS = -pg
|
aria2c_LDFLAGS = -pg
|
||||||
AM_CPPFLAGS = -Wall\
|
AM_CPPFLAGS = -Wall\
|
||||||
-I../lib -I../intl -I$(top_srcdir)/intl\
|
-I../lib -I../intl -I$(top_srcdir)/intl\
|
||||||
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
@LIBGNUTLS_CFLAGS@ @LIBGCRYPT_CFLAGS@ @OPENSSL_CFLAGS@ @XML_CPPFLAGS@\
|
||||||
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
@LIBARES_CPPFLAGS@ @LIBCARES_CPPFLAGS@\
|
||||||
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@# -pg
|
-D_FILE_OFFSET_BITS=64 -DLOCALEDIR=\"$(localedir)\" @DEFS@ -pg
|
||||||
|
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
|
@ -769,6 +776,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtUnchokeMessage.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtUnchokeMessage.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ByteArrayDiskWriter.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ByteArrayDiskWriter.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CheckIntegrityCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CheckIntegrityCommand.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChecksumCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkChecksumValidator.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkChecksumValidator.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkedEncoding.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkedEncoding.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Command.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Command.Po@am__quote@
|
||||||
|
@ -828,6 +836,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpResponse.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpResponse.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpResponseCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpResponseCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitiateConnectionCommandFactory.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitiateConnectionCommandFactory.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChecksumValidator.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChunkChecksumValidator.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChunkChecksumValidator.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/List.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/List.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogFactory.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogFactory.Po@am__quote@
|
||||||
|
@ -853,6 +862,7 @@ distclean-compile:
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerListenCommand.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerListenCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtil.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtil.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Piece.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Piece.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RealtimeCommand.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactory.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactory.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroup.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestGroup.Po@am__quote@
|
||||||
|
|
|
@ -40,6 +40,7 @@ MetalinkEntry::MetalinkEntry():
|
||||||
size(0)
|
size(0)
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
,
|
,
|
||||||
|
checksum(0),
|
||||||
chunkChecksum(0)
|
chunkChecksum(0)
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
string language;
|
string language;
|
||||||
string os;
|
string os;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
Checksum checksum;
|
ChecksumHandle checksum;
|
||||||
public:
|
public:
|
||||||
MetalinkResources resources;
|
MetalinkResources resources;
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
|
|
|
@ -106,7 +106,7 @@ RequestInfos MetalinkRequestInfo::execute() {
|
||||||
FindBitTorrentUrl());
|
FindBitTorrentUrl());
|
||||||
Strings urls;
|
Strings urls;
|
||||||
int maxConnection = 0;
|
int maxConnection = 0;
|
||||||
Checksum checksum;
|
ChecksumHandle checksum = 0;
|
||||||
if(itr == entry->resources.end()) {
|
if(itr == entry->resources.end()) {
|
||||||
entry->reorderResourcesByPreference();
|
entry->reorderResourcesByPreference();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#include "RealtimeCommand.h"
|
||||||
|
|
||||||
|
bool RealtimeCommand::execute()
|
||||||
|
{
|
||||||
|
setStatusRealtime();
|
||||||
|
_e->noWait = true;
|
||||||
|
try {
|
||||||
|
return executeInternal();
|
||||||
|
} catch(Exception* e) {
|
||||||
|
_requestGroup->getSegmentMan()->errors++;
|
||||||
|
bool r = handleException(e);
|
||||||
|
delete e;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/* <!-- copyright */
|
||||||
|
/*
|
||||||
|
* aria2 - The high speed download utility
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*/
|
||||||
|
/* copyright --> */
|
||||||
|
#ifndef _D_REALTIME_COMMAND_H_
|
||||||
|
#define _D_REALTIME_COMMAND_H_
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "RequestGroup.h"
|
||||||
|
#include "DownloadEngine.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
|
||||||
|
class RealtimeCommand : public Command {
|
||||||
|
protected:
|
||||||
|
RequestGroup* _requestGroup;
|
||||||
|
DownloadEngine* _e;
|
||||||
|
public:
|
||||||
|
RealtimeCommand(int cuid, RequestGroup* requestGroup, DownloadEngine* e):
|
||||||
|
Command(cuid),
|
||||||
|
_requestGroup(requestGroup),
|
||||||
|
_e(e) {}
|
||||||
|
|
||||||
|
virtual ~RealtimeCommand() {}
|
||||||
|
|
||||||
|
virtual bool execute();
|
||||||
|
|
||||||
|
virtual bool executeInternal() = 0;
|
||||||
|
|
||||||
|
virtual bool handleException(Exception* e) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _D_REALTIME_COMMAND_H_
|
|
@ -191,21 +191,28 @@ bool RequestGroup::downloadFinishedByFileLength()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestGroup::prepareForNextAction(int cuid, const RequestHandle& req, DownloadEngine* e)
|
void RequestGroup::prepareForNextAction(int cuid, const RequestHandle& req, DownloadEngine* e, DownloadCommand* downloadCommand)
|
||||||
{
|
{
|
||||||
File existingFile(getFilePath());
|
File existingFile(getFilePath());
|
||||||
if(existingFile.size() > 0 && _option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
if(existingFile.size() > 0 && _option->get(PREF_CHECK_INTEGRITY) == V_TRUE) {
|
||||||
CheckIntegrityCommand* command = new CheckIntegrityCommand(cuid, req, this, e);
|
CheckIntegrityCommand* command = new CheckIntegrityCommand(cuid, req, this, e);
|
||||||
|
command->setNextDownloadCommand(downloadCommand);
|
||||||
command->initValidator();
|
command->initValidator();
|
||||||
e->commands.push_back(command);
|
e->commands.push_back(command);
|
||||||
} else if(needsFileAllocation()) {
|
} else if(needsFileAllocation()) {
|
||||||
e->_fileAllocationMan->pushFileAllocationEntry(new FileAllocationEntry(cuid, req, this));
|
FileAllocationEntryHandle entry = new FileAllocationEntry(cuid, req, this);
|
||||||
|
entry->setNextDownloadCommand(downloadCommand);
|
||||||
|
e->_fileAllocationMan->pushFileAllocationEntry(entry);
|
||||||
} else {
|
} else {
|
||||||
int32_t numCommandsToGenerate = 15;
|
if(downloadCommand) {
|
||||||
Commands commands = getNextCommand(e, numCommandsToGenerate);
|
e->commands.push_back(downloadCommand);
|
||||||
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, req, this, e);
|
} else {
|
||||||
commands.push_front(command);
|
int32_t numCommandsToGenerate = 15;
|
||||||
e->addCommand(commands);
|
Commands commands = getNextCommand(e, numCommandsToGenerate);
|
||||||
|
Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, req, this, e);
|
||||||
|
commands.push_front(command);
|
||||||
|
e->addCommand(commands);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
#include "SegmentManFactory.h"
|
#include "SegmentManFactory.h"
|
||||||
#include "DefaultSegmentManFactory.h"
|
#include "DefaultSegmentManFactory.h"
|
||||||
|
|
||||||
|
class DownloadCommand;
|
||||||
|
|
||||||
class DownloadEngine;
|
class DownloadEngine;
|
||||||
|
|
||||||
class RequestGroup {
|
class RequestGroup {
|
||||||
|
@ -57,7 +59,7 @@ private:
|
||||||
const Option* _option;
|
const Option* _option;
|
||||||
const Logger* logger;
|
const Logger* logger;
|
||||||
ChunkChecksumHandle _chunkChecksum;
|
ChunkChecksumHandle _chunkChecksum;
|
||||||
Checksum _checksum;
|
ChecksumHandle _checksum;
|
||||||
|
|
||||||
void validateFilename(const string& expectedFilename,
|
void validateFilename(const string& expectedFilename,
|
||||||
const string& actualFilename) const;
|
const string& actualFilename) const;
|
||||||
|
@ -79,6 +81,7 @@ public:
|
||||||
_option(option),
|
_option(option),
|
||||||
logger(LogFactory::getInstance()),
|
logger(LogFactory::getInstance()),
|
||||||
_chunkChecksum(0),
|
_chunkChecksum(0),
|
||||||
|
_checksum(0),
|
||||||
numConnection(0),
|
numConnection(0),
|
||||||
isTorrent(false) {}
|
isTorrent(false) {}
|
||||||
|
|
||||||
|
@ -186,15 +189,20 @@ public:
|
||||||
|
|
||||||
void loadAndOpenFile();
|
void loadAndOpenFile();
|
||||||
|
|
||||||
void prepareForNextAction(int cuid, const RequestHandle& req, DownloadEngine* e);
|
void prepareForNextAction(int cuid, const RequestHandle& req, DownloadEngine* e, DownloadCommand* downloadCommand = 0);
|
||||||
|
|
||||||
bool downloadFinishedByFileLength();
|
bool downloadFinishedByFileLength();
|
||||||
|
|
||||||
void setChecksum(const Checksum& checksum)
|
void setChecksum(const ChecksumHandle& checksum)
|
||||||
{
|
{
|
||||||
_checksum = checksum;
|
_checksum = checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChecksumHandle getChecksum() const
|
||||||
|
{
|
||||||
|
return _checksum;
|
||||||
|
}
|
||||||
|
|
||||||
const string& getHintFilename() const
|
const string& getHintFilename() const
|
||||||
{
|
{
|
||||||
return _hintFilename;
|
return _hintFilename;
|
||||||
|
|
|
@ -112,13 +112,15 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
|
||||||
string md;
|
string md;
|
||||||
md = Util::toLower(Util::trim(xpathContent(xpath+"/m:verification/m:hash[@type=\"sha1\"]")));
|
md = Util::toLower(Util::trim(xpathContent(xpath+"/m:verification/m:hash[@type=\"sha1\"]")));
|
||||||
if(md.size() > 0) {
|
if(md.size() > 0) {
|
||||||
entry->checksum.setMessageDigest(md);
|
entry->checksum = new Checksum();
|
||||||
entry->checksum.setDigestAlgo(DIGEST_ALGO_SHA1);
|
entry->checksum->setMessageDigest(md);
|
||||||
|
entry->checksum->setDigestAlgo(DIGEST_ALGO_SHA1);
|
||||||
} else {
|
} else {
|
||||||
md = Util::toLower(Util::trim(xpathContent(xpath+"/m:verification/m:hash[@type=\"md5\"]")));
|
md = Util::toLower(Util::trim(xpathContent(xpath+"/m:verification/m:hash[@type=\"md5\"]")));
|
||||||
if(md.size() > 0) {
|
if(md.size() > 0) {
|
||||||
entry->checksum.setMessageDigest(md);
|
entry->checksum = new Checksum();
|
||||||
entry->checksum.setDigestAlgo(DIGEST_ALGO_MD5);
|
entry->checksum->setMessageDigest(md);
|
||||||
|
entry->checksum->setDigestAlgo(DIGEST_ALGO_MD5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string piecesPath = xpath+"/m:verification/m:pieces";
|
string piecesPath = xpath+"/m:verification/m:pieces";
|
||||||
|
|
|
@ -79,5 +79,6 @@ typedef deque<string> Strings;
|
||||||
typedef deque<int32_t> Integers;
|
typedef deque<int32_t> Integers;
|
||||||
|
|
||||||
#define OPEN_MODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
|
#define OPEN_MODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
|
||||||
|
#define DIR_OPEN_MODE S_IRWXU|S_IRWXG|S_IRWXO
|
||||||
|
|
||||||
#endif // _D_COMMON_H_
|
#endif // _D_COMMON_H_
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
#define MSG_GOT_WRONG_PIECE _("CUID#%d - we got wrong piece. index=%d")
|
#define MSG_GOT_WRONG_PIECE _("CUID#%d - we got wrong piece. index=%d")
|
||||||
#define MSG_DOWNLOAD_NOT_COMPLETE _("CUID#%d - Download not complete: %s")
|
#define MSG_DOWNLOAD_NOT_COMPLETE _("CUID#%d - Download not complete: %s")
|
||||||
#define MSG_DOWNLOAD_ALREADY_COMPLETED _("CUID#%d - Download already completed: %s")
|
#define MSG_DOWNLOAD_ALREADY_COMPLETED _("CUID#%d - Download already completed: %s")
|
||||||
|
#define MSG_GOOD_CHECKSUM _("CUID#%d - Good checksum: %s")
|
||||||
|
#define MSG_BAD_CHECKSUM _("CUID#%d - Bad checksum: %s")
|
||||||
|
|
||||||
#define MSG_TRACKER_WARNING_MESSAGE _("Tracker returned warning message: %s")
|
#define MSG_TRACKER_WARNING_MESSAGE _("Tracker returned warning message: %s")
|
||||||
#define MSG_SEGMENT_FILE_EXISTS _("The segment file %s exists.")
|
#define MSG_SEGMENT_FILE_EXISTS _("The segment file %s exists.")
|
||||||
|
|
|
@ -146,5 +146,6 @@ public:
|
||||||
}
|
}
|
||||||
#endif // HAVE_LIBGCRYPT
|
#endif // HAVE_LIBGCRYPT
|
||||||
};
|
};
|
||||||
|
typedef SharedHandle<MessageDigestContext> MessageDigestContextHandle;
|
||||||
#endif // ENABLE_SSL
|
#endif // ENABLE_SSL
|
||||||
#endif // _D_MESSAGE_DIGEST_H_
|
#endif // _D_MESSAGE_DIGEST_H_
|
||||||
|
|
|
@ -20,7 +20,6 @@ class HttpResponseTest : public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testIsTransferEncodingSpecified);
|
CPPUNIT_TEST(testIsTransferEncodingSpecified);
|
||||||
CPPUNIT_TEST(testGetTransferEncoding);
|
CPPUNIT_TEST(testGetTransferEncoding);
|
||||||
CPPUNIT_TEST(testGetTransferDecoder);
|
CPPUNIT_TEST(testGetTransferDecoder);
|
||||||
CPPUNIT_TEST(testValidateFilename);
|
|
||||||
CPPUNIT_TEST(testValidateResponse);
|
CPPUNIT_TEST(testValidateResponse);
|
||||||
CPPUNIT_TEST(testValidateResponse_good_range);
|
CPPUNIT_TEST(testValidateResponse_good_range);
|
||||||
CPPUNIT_TEST(testValidateResponse_bad_range);
|
CPPUNIT_TEST(testValidateResponse_bad_range);
|
||||||
|
@ -44,7 +43,6 @@ public:
|
||||||
void testIsTransferEncodingSpecified();
|
void testIsTransferEncodingSpecified();
|
||||||
void testGetTransferEncoding();
|
void testGetTransferEncoding();
|
||||||
void testGetTransferDecoder();
|
void testGetTransferDecoder();
|
||||||
void testValidateFilename();
|
|
||||||
void testValidateResponse();
|
void testValidateResponse();
|
||||||
void testValidateResponse_good_range();
|
void testValidateResponse_good_range();
|
||||||
void testValidateResponse_bad_range();
|
void testValidateResponse_bad_range();
|
||||||
|
@ -220,38 +218,6 @@ void HttpResponseTest::testGetTransferDecoder()
|
||||||
CPPUNIT_ASSERT(!httpResponse.getTransferDecoder().isNull());
|
CPPUNIT_ASSERT(!httpResponse.getTransferDecoder().isNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpResponseTest::testValidateFilename()
|
|
||||||
{
|
|
||||||
HttpResponse httpResponse;
|
|
||||||
|
|
||||||
try {
|
|
||||||
httpResponse.validateFilename("");
|
|
||||||
} catch(...) {
|
|
||||||
CPPUNIT_FAIL("");
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpHeaderHandle httpHeader = new HttpHeader();
|
|
||||||
HttpRequestHandle httpRequest = new HttpRequest();
|
|
||||||
RequestHandle request = new Request();
|
|
||||||
request->setUrl("http://localhost/archives/aria2-1.0.0.tar.bz2");
|
|
||||||
httpRequest->setRequest(request);
|
|
||||||
|
|
||||||
httpResponse.setHttpHeader(httpHeader);
|
|
||||||
httpResponse.setHttpRequest(httpRequest);
|
|
||||||
|
|
||||||
try {
|
|
||||||
httpResponse.validateFilename("aria2-1.0.0.tar.bz2");
|
|
||||||
} catch(...) {
|
|
||||||
CPPUNIT_FAIL("");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
httpResponse.validateFilename("aria2-current.tar.bz2");
|
|
||||||
CPPUNIT_FAIL("exception must be threw.");
|
|
||||||
} catch(...) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HttpResponseTest::testValidateResponse()
|
void HttpResponseTest::testValidateResponse()
|
||||||
{
|
{
|
||||||
HttpResponse httpResponse;
|
HttpResponse httpResponse;
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
#include "IteratableChecksumValidator.h"
|
||||||
|
#include "DefaultDiskWriter.h"
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class IteratableChecksumValidatorTest:public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(IteratableChecksumValidatorTest);
|
||||||
|
CPPUNIT_TEST(testValidate);
|
||||||
|
CPPUNIT_TEST(testValidate2);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void testValidate();
|
||||||
|
void testValidate2();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( IteratableChecksumValidatorTest );
|
||||||
|
|
||||||
|
void IteratableChecksumValidatorTest::testValidate() {
|
||||||
|
BitfieldMan bitfieldMan(100, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
|
||||||
|
ChecksumHandle checksum = new Checksum("898a81b8e0181280ae2ee1b81e269196d91e869a", DIGEST_ALGO_SHA1);
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
IteratableChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
validator.setBitfield(&bitfieldMan);
|
||||||
|
validator.setChecksum(checksum);
|
||||||
|
|
||||||
|
validator.init();
|
||||||
|
while(!validator.finished()) {
|
||||||
|
validator.validateChunk();
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isAllBitSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
void IteratableChecksumValidatorTest::testValidate2() {
|
||||||
|
BitfieldMan bitfieldMan(100, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
|
||||||
|
ChecksumHandle checksum = new Checksum("ffffffffffffffffffffffffffffffffffffffff", DIGEST_ALGO_SHA1);
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
IteratableChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
validator.setBitfield(&bitfieldMan);
|
||||||
|
validator.setChecksum(checksum);
|
||||||
|
|
||||||
|
validator.init();
|
||||||
|
while(!validator.finished()) {
|
||||||
|
validator.validateChunk();
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isAllBitSet());
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void IteratableChecksumValidatorTest::testValidate3() {
|
||||||
|
BitfieldMan bitfieldMan(50, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
Strings checksums;
|
||||||
|
checksums.push_back("898a81b8e0181280ae2ee1b81e269196d91e869a");
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
IteratableChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
|
||||||
|
validator.validate(&bitfieldMan, checksums, 250);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isAllBitSet());
|
||||||
|
|
||||||
|
checksums[0] = "ffffffffffffffffffffffffffffffffffffffff";
|
||||||
|
|
||||||
|
validator.validate(&bitfieldMan, checksums, 250);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(0));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(1));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(3));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IteratableChecksumValidatorTest::testValidate4() {
|
||||||
|
BitfieldMan bitfieldMan(70, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
Strings checksums(&csArray[0], &csArray[3]);
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
IteratableChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
|
||||||
|
validator.validate(&bitfieldMan, checksums, 100);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isAllBitSet());
|
||||||
|
|
||||||
|
checksums[1] = "ffffffffffffffffffffffffffffffffffffffff";
|
||||||
|
validator.validate(&bitfieldMan, checksums, 100);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(0));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(1));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(3));
|
||||||
|
}
|
||||||
|
*/
|
|
@ -0,0 +1,156 @@
|
||||||
|
#include "IteratableChunkChecksumValidator.h"
|
||||||
|
#include "DefaultDiskWriter.h"
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class IteratableChunkChecksumValidatorTest:public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(IteratableChunkChecksumValidatorTest);
|
||||||
|
CPPUNIT_TEST(testValidate);
|
||||||
|
/*
|
||||||
|
CPPUNIT_TEST(testValidate2);
|
||||||
|
CPPUNIT_TEST(testValidate3);
|
||||||
|
CPPUNIT_TEST(testValidate4);
|
||||||
|
*/
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
private:
|
||||||
|
|
||||||
|
static const char* csArray[];// = { "29b0e7878271645fffb7eec7db4a7473a1c00bc1",
|
||||||
|
// "4df75a661cb7eb2733d9cdaa7f772eae3a4e2976",
|
||||||
|
// "0a4ea2f7dd7c52ddf2099a444ab2184b4d341bdb" };
|
||||||
|
public:
|
||||||
|
void setUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void testValidate();
|
||||||
|
/*
|
||||||
|
void testValidate2();
|
||||||
|
void testValidate3();
|
||||||
|
void testValidate4();
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( IteratableChunkChecksumValidatorTest );
|
||||||
|
|
||||||
|
const char* IteratableChunkChecksumValidatorTest::csArray[] = { "29b0e7878271645fffb7eec7db4a7473a1c00bc1",
|
||||||
|
"4df75a661cb7eb2733d9cdaa7f772eae3a4e2976",
|
||||||
|
"0a4ea2f7dd7c52ddf2099a444ab2184b4d341bdb" };
|
||||||
|
|
||||||
|
void IteratableChunkChecksumValidatorTest::testValidate() {
|
||||||
|
BitfieldMan bitfieldMan(100, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
Strings checksums(&csArray[0], &csArray[3]);
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
ChunkChecksumHandle chunkChecksum = new ChunkChecksum(DIGEST_ALGO_SHA1,
|
||||||
|
checksums,
|
||||||
|
100);
|
||||||
|
IteratableChunkChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
validator.setBitfield(&bitfieldMan);
|
||||||
|
validator.setChunkChecksum(chunkChecksum);
|
||||||
|
|
||||||
|
validator.init();
|
||||||
|
validator.validateChunk();
|
||||||
|
CPPUNIT_ASSERT(!validator.finished());
|
||||||
|
validator.validateChunk();
|
||||||
|
CPPUNIT_ASSERT(!validator.finished());
|
||||||
|
validator.validateChunk();
|
||||||
|
CPPUNIT_ASSERT(validator.finished());
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isAllBitSet());
|
||||||
|
|
||||||
|
checksums[1] = "ffffffffffffffffffffffffffffffffffffffff";
|
||||||
|
chunkChecksum = new ChunkChecksum(DIGEST_ALGO_SHA1,
|
||||||
|
checksums,
|
||||||
|
100);
|
||||||
|
validator.setChunkChecksum(chunkChecksum);
|
||||||
|
|
||||||
|
validator.init();
|
||||||
|
while(!validator.finished()) {
|
||||||
|
validator.validateChunk();
|
||||||
|
}
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(0));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(1));
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(2));
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void IteratableChunkChecksumValidatorTest::testValidate2() {
|
||||||
|
BitfieldMan bitfieldMan(50, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
Strings checksums(&csArray[0], &csArray[3]);
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
IteratableChunkChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
|
||||||
|
validator.validate(&bitfieldMan, checksums, 100);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isAllBitSet());
|
||||||
|
|
||||||
|
checksums[1] = "ffffffffffffffffffffffffffffffffffffffff";
|
||||||
|
validator.validate(&bitfieldMan, checksums, 100);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(0));
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(1));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(3));
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IteratableChunkChecksumValidatorTest::testValidate3() {
|
||||||
|
BitfieldMan bitfieldMan(50, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
Strings checksums;
|
||||||
|
checksums.push_back("898a81b8e0181280ae2ee1b81e269196d91e869a");
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
IteratableChunkChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
|
||||||
|
validator.validate(&bitfieldMan, checksums, 250);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isAllBitSet());
|
||||||
|
|
||||||
|
checksums[0] = "ffffffffffffffffffffffffffffffffffffffff";
|
||||||
|
|
||||||
|
validator.validate(&bitfieldMan, checksums, 250);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(0));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(1));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(3));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IteratableChunkChecksumValidatorTest::testValidate4() {
|
||||||
|
BitfieldMan bitfieldMan(70, 250);
|
||||||
|
bitfieldMan.setAllBit();
|
||||||
|
Strings checksums(&csArray[0], &csArray[3]);
|
||||||
|
|
||||||
|
DefaultDiskWriterHandle diskWriter = new DefaultDiskWriter();
|
||||||
|
diskWriter->openExistingFile("chunkChecksumTestFile250.txt");
|
||||||
|
|
||||||
|
IteratableChunkChecksumValidator validator;
|
||||||
|
validator.setDiskWriter(diskWriter);
|
||||||
|
|
||||||
|
validator.validate(&bitfieldMan, checksums, 100);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isAllBitSet());
|
||||||
|
|
||||||
|
checksums[1] = "ffffffffffffffffffffffffffffffffffffffff";
|
||||||
|
validator.validate(&bitfieldMan, checksums, 100);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(0));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(1));
|
||||||
|
CPPUNIT_ASSERT(!bitfieldMan.isBitSet(2));
|
||||||
|
CPPUNIT_ASSERT(bitfieldMan.isBitSet(3));
|
||||||
|
}
|
||||||
|
*/
|
145
test/Makefile.am
145
test/Makefile.am
|
@ -1,78 +1,79 @@
|
||||||
TESTS = aria2c
|
TESTS = aria2c
|
||||||
check_PROGRAMS = $(TESTS)
|
check_PROGRAMS = $(TESTS)
|
||||||
aria2c_SOURCES = AllTest.cc\
|
aria2c_SOURCES = AllTest.cc\
|
||||||
IteratableChunkChecksumValidatorTest.cc
|
IteratableChecksumValidatorTest.cc\
|
||||||
# UriFileListParserTest.cc
|
IteratableChunkChecksumValidatorTest.cc\
|
||||||
# PeerTest.cc\
|
UriFileListParserTest.cc\
|
||||||
# DefaultPeerStorageTest.cc\
|
PeerTest.cc\
|
||||||
# RequestFactoryTest.cc\
|
DefaultPeerStorageTest.cc\
|
||||||
# NetrcAuthResolverTest.cc\
|
RequestFactoryTest.cc\
|
||||||
# DefaultAuthResolverTest.cc\
|
NetrcAuthResolverTest.cc\
|
||||||
# RequestTest.cc\
|
DefaultAuthResolverTest.cc\
|
||||||
# HttpRequestTest.cc\
|
RequestTest.cc\
|
||||||
# UtilTest.cc\
|
HttpRequestTest.cc\
|
||||||
# OptionHandlerTest.cc\
|
UtilTest.cc\
|
||||||
# SegmentManTest.cc\
|
OptionHandlerTest.cc\
|
||||||
# BitfieldManTest.cc\
|
SegmentManTest.cc\
|
||||||
# GlowFileAllocatorTest.cc\
|
BitfieldManTest.cc\
|
||||||
# NetrcTest.cc\
|
GlowFileAllocatorTest.cc\
|
||||||
# SingletonHolderTest.cc\
|
NetrcTest.cc\
|
||||||
# HttpHeaderTest.cc\
|
SingletonHolderTest.cc\
|
||||||
# HttpResponseTest.cc\
|
HttpHeaderTest.cc\
|
||||||
# SharedHandleTest.cc\
|
HttpResponseTest.cc\
|
||||||
# ChunkedEncodingTest.cc\
|
SharedHandleTest.cc\
|
||||||
# FileTest.cc\
|
ChunkedEncodingTest.cc\
|
||||||
# OptionTest.cc\
|
FileTest.cc\
|
||||||
# Base64Test.cc\
|
OptionTest.cc\
|
||||||
# CookieBoxTest.cc\
|
Base64Test.cc\
|
||||||
# DataTest.cc\
|
CookieBoxTest.cc\
|
||||||
# DictionaryTest.cc\
|
DataTest.cc\
|
||||||
# ListTest.cc\
|
DictionaryTest.cc\
|
||||||
# MetaFileUtilTest.cc\
|
ListTest.cc\
|
||||||
# ShaVisitorTest.cc\
|
MetaFileUtilTest.cc\
|
||||||
# PeerMessageUtilTest.cc\
|
ShaVisitorTest.cc\
|
||||||
# DefaultDiskWriterTest.cc\
|
PeerMessageUtilTest.cc\
|
||||||
# MultiDiskAdaptorTest.cc\
|
DefaultDiskWriterTest.cc\
|
||||||
# Xml2MetalinkProcessorTest.cc\
|
MultiDiskAdaptorTest.cc\
|
||||||
# MetalinkerTest.cc\
|
Xml2MetalinkProcessorTest.cc\
|
||||||
# MetalinkEntryTest.cc\
|
MetalinkerTest.cc\
|
||||||
# FeatureConfigTest.cc\
|
MetalinkEntryTest.cc\
|
||||||
# ShareRatioSeedCriteriaTest.cc\
|
FeatureConfigTest.cc\
|
||||||
# TimeSeedCriteriaTest.cc\
|
ShareRatioSeedCriteriaTest.cc\
|
||||||
# SpeedCalcTest.cc\
|
TimeSeedCriteriaTest.cc\
|
||||||
# DefaultPeerListProcessorTest.cc\
|
SpeedCalcTest.cc\
|
||||||
# AnnounceListTest.cc\
|
DefaultPeerListProcessorTest.cc\
|
||||||
# TrackerWatcherCommandTest.cc\
|
AnnounceListTest.cc\
|
||||||
# DefaultBtContextTest.cc\
|
TrackerWatcherCommandTest.cc\
|
||||||
# DefaultPieceStorageTest.cc\
|
DefaultBtContextTest.cc\
|
||||||
# DefaultBtAnnounceTest.cc\
|
DefaultPieceStorageTest.cc\
|
||||||
# BtRegistryTest.cc\
|
DefaultBtAnnounceTest.cc\
|
||||||
# DefaultBtMessageDispatcherTest.cc\
|
BtRegistryTest.cc\
|
||||||
# MockPeerStorage.h\
|
DefaultBtMessageDispatcherTest.cc\
|
||||||
# DefaultBtRequestFactoryTest.cc\
|
MockPeerStorage.h\
|
||||||
# BtAllowedFastMessageTest.cc\
|
DefaultBtRequestFactoryTest.cc\
|
||||||
# BtBitfieldMessageTest.cc\
|
BtAllowedFastMessageTest.cc\
|
||||||
# BtCancelMessageTest.cc\
|
BtBitfieldMessageTest.cc\
|
||||||
# BtChokeMessageTest.cc\
|
BtCancelMessageTest.cc\
|
||||||
# BtHaveAllMessageTest.cc\
|
BtChokeMessageTest.cc\
|
||||||
# BtHaveMessageTest.cc\
|
BtHaveAllMessageTest.cc\
|
||||||
# BtHaveNoneMessageTest.cc\
|
BtHaveMessageTest.cc\
|
||||||
# BtInterestedMessageTest.cc\
|
BtHaveNoneMessageTest.cc\
|
||||||
# BtKeepAliveMessageTest.cc\
|
BtInterestedMessageTest.cc\
|
||||||
# BtNotInterestedMessageTest.cc\
|
BtKeepAliveMessageTest.cc\
|
||||||
# BtPieceMessageTest.cc\
|
BtNotInterestedMessageTest.cc\
|
||||||
# BtPortMessageTest.cc\
|
BtPieceMessageTest.cc\
|
||||||
# BtRejectMessageTest.cc\
|
BtPortMessageTest.cc\
|
||||||
# BtRequestMessageTest.cc\
|
BtRejectMessageTest.cc\
|
||||||
# BtSuggestPieceMessageTest.cc\
|
BtRequestMessageTest.cc\
|
||||||
# BtUnchokeMessageTest.cc\
|
BtSuggestPieceMessageTest.cc\
|
||||||
# BtHandshakeMessageTest.cc\
|
BtUnchokeMessageTest.cc\
|
||||||
# MockBtMessageDispatcher.h\
|
BtHandshakeMessageTest.cc\
|
||||||
# FixedNumberRandomizer.h\
|
MockBtMessageDispatcher.h\
|
||||||
# MockBtMessageFactory.h\
|
FixedNumberRandomizer.h\
|
||||||
# MockBtMessage.h\
|
MockBtMessageFactory.h\
|
||||||
# ConsoleFileAllocationMonitorTest.cc\
|
MockBtMessage.h\
|
||||||
# ChunkChecksumValidatorTest.cc
|
ConsoleFileAllocationMonitorTest.cc\
|
||||||
|
ChunkChecksumValidatorTest.cc
|
||||||
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
||||||
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
||||||
|
|
||||||
|
|
260
test/Makefile.in
260
test/Makefile.in
|
@ -58,7 +58,49 @@ CONFIG_HEADER = $(top_builddir)/config.h
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES =
|
||||||
am__EXEEXT_1 = aria2c$(EXEEXT)
|
am__EXEEXT_1 = aria2c$(EXEEXT)
|
||||||
am_aria2c_OBJECTS = AllTest.$(OBJEXT) \
|
am_aria2c_OBJECTS = AllTest.$(OBJEXT) \
|
||||||
IteratableChunkChecksumValidatorTest.$(OBJEXT)
|
IteratableChecksumValidatorTest.$(OBJEXT) \
|
||||||
|
IteratableChunkChecksumValidatorTest.$(OBJEXT) \
|
||||||
|
UriFileListParserTest.$(OBJEXT) PeerTest.$(OBJEXT) \
|
||||||
|
DefaultPeerStorageTest.$(OBJEXT) RequestFactoryTest.$(OBJEXT) \
|
||||||
|
NetrcAuthResolverTest.$(OBJEXT) \
|
||||||
|
DefaultAuthResolverTest.$(OBJEXT) RequestTest.$(OBJEXT) \
|
||||||
|
HttpRequestTest.$(OBJEXT) UtilTest.$(OBJEXT) \
|
||||||
|
OptionHandlerTest.$(OBJEXT) SegmentManTest.$(OBJEXT) \
|
||||||
|
BitfieldManTest.$(OBJEXT) GlowFileAllocatorTest.$(OBJEXT) \
|
||||||
|
NetrcTest.$(OBJEXT) SingletonHolderTest.$(OBJEXT) \
|
||||||
|
HttpHeaderTest.$(OBJEXT) HttpResponseTest.$(OBJEXT) \
|
||||||
|
SharedHandleTest.$(OBJEXT) ChunkedEncodingTest.$(OBJEXT) \
|
||||||
|
FileTest.$(OBJEXT) OptionTest.$(OBJEXT) Base64Test.$(OBJEXT) \
|
||||||
|
CookieBoxTest.$(OBJEXT) DataTest.$(OBJEXT) \
|
||||||
|
DictionaryTest.$(OBJEXT) ListTest.$(OBJEXT) \
|
||||||
|
MetaFileUtilTest.$(OBJEXT) ShaVisitorTest.$(OBJEXT) \
|
||||||
|
PeerMessageUtilTest.$(OBJEXT) DefaultDiskWriterTest.$(OBJEXT) \
|
||||||
|
MultiDiskAdaptorTest.$(OBJEXT) \
|
||||||
|
Xml2MetalinkProcessorTest.$(OBJEXT) MetalinkerTest.$(OBJEXT) \
|
||||||
|
MetalinkEntryTest.$(OBJEXT) FeatureConfigTest.$(OBJEXT) \
|
||||||
|
ShareRatioSeedCriteriaTest.$(OBJEXT) \
|
||||||
|
TimeSeedCriteriaTest.$(OBJEXT) SpeedCalcTest.$(OBJEXT) \
|
||||||
|
DefaultPeerListProcessorTest.$(OBJEXT) \
|
||||||
|
AnnounceListTest.$(OBJEXT) TrackerWatcherCommandTest.$(OBJEXT) \
|
||||||
|
DefaultBtContextTest.$(OBJEXT) \
|
||||||
|
DefaultPieceStorageTest.$(OBJEXT) \
|
||||||
|
DefaultBtAnnounceTest.$(OBJEXT) BtRegistryTest.$(OBJEXT) \
|
||||||
|
DefaultBtMessageDispatcherTest.$(OBJEXT) \
|
||||||
|
DefaultBtRequestFactoryTest.$(OBJEXT) \
|
||||||
|
BtAllowedFastMessageTest.$(OBJEXT) \
|
||||||
|
BtBitfieldMessageTest.$(OBJEXT) BtCancelMessageTest.$(OBJEXT) \
|
||||||
|
BtChokeMessageTest.$(OBJEXT) BtHaveAllMessageTest.$(OBJEXT) \
|
||||||
|
BtHaveMessageTest.$(OBJEXT) BtHaveNoneMessageTest.$(OBJEXT) \
|
||||||
|
BtInterestedMessageTest.$(OBJEXT) \
|
||||||
|
BtKeepAliveMessageTest.$(OBJEXT) \
|
||||||
|
BtNotInterestedMessageTest.$(OBJEXT) \
|
||||||
|
BtPieceMessageTest.$(OBJEXT) BtPortMessageTest.$(OBJEXT) \
|
||||||
|
BtRejectMessageTest.$(OBJEXT) BtRequestMessageTest.$(OBJEXT) \
|
||||||
|
BtSuggestPieceMessageTest.$(OBJEXT) \
|
||||||
|
BtUnchokeMessageTest.$(OBJEXT) \
|
||||||
|
BtHandshakeMessageTest.$(OBJEXT) \
|
||||||
|
ConsoleFileAllocationMonitorTest.$(OBJEXT) \
|
||||||
|
ChunkChecksumValidatorTest.$(OBJEXT)
|
||||||
aria2c_OBJECTS = $(am_aria2c_OBJECTS)
|
aria2c_OBJECTS = $(am_aria2c_OBJECTS)
|
||||||
am__DEPENDENCIES_1 =
|
am__DEPENDENCIES_1 =
|
||||||
aria2c_DEPENDENCIES = ../src/libaria2c.a $(am__DEPENDENCIES_1)
|
aria2c_DEPENDENCIES = ../src/libaria2c.a $(am__DEPENDENCIES_1)
|
||||||
|
@ -70,6 +112,10 @@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||||
CXXLD = $(CXX)
|
CXXLD = $(CXX)
|
||||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
||||||
-o $@
|
-o $@
|
||||||
|
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||||
|
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
CCLD = $(CC)
|
||||||
|
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
SOURCES = $(aria2c_SOURCES)
|
SOURCES = $(aria2c_SOURCES)
|
||||||
DIST_SOURCES = $(aria2c_SOURCES)
|
DIST_SOURCES = $(aria2c_SOURCES)
|
||||||
ETAGS = etags
|
ETAGS = etags
|
||||||
|
@ -219,79 +265,80 @@ sysconfdir = @sysconfdir@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
TESTS = aria2c
|
TESTS = aria2c
|
||||||
aria2c_SOURCES = AllTest.cc\
|
aria2c_SOURCES = AllTest.cc\
|
||||||
IteratableChunkChecksumValidatorTest.cc
|
IteratableChecksumValidatorTest.cc\
|
||||||
|
IteratableChunkChecksumValidatorTest.cc\
|
||||||
|
UriFileListParserTest.cc\
|
||||||
|
PeerTest.cc\
|
||||||
|
DefaultPeerStorageTest.cc\
|
||||||
|
RequestFactoryTest.cc\
|
||||||
|
NetrcAuthResolverTest.cc\
|
||||||
|
DefaultAuthResolverTest.cc\
|
||||||
|
RequestTest.cc\
|
||||||
|
HttpRequestTest.cc\
|
||||||
|
UtilTest.cc\
|
||||||
|
OptionHandlerTest.cc\
|
||||||
|
SegmentManTest.cc\
|
||||||
|
BitfieldManTest.cc\
|
||||||
|
GlowFileAllocatorTest.cc\
|
||||||
|
NetrcTest.cc\
|
||||||
|
SingletonHolderTest.cc\
|
||||||
|
HttpHeaderTest.cc\
|
||||||
|
HttpResponseTest.cc\
|
||||||
|
SharedHandleTest.cc\
|
||||||
|
ChunkedEncodingTest.cc\
|
||||||
|
FileTest.cc\
|
||||||
|
OptionTest.cc\
|
||||||
|
Base64Test.cc\
|
||||||
|
CookieBoxTest.cc\
|
||||||
|
DataTest.cc\
|
||||||
|
DictionaryTest.cc\
|
||||||
|
ListTest.cc\
|
||||||
|
MetaFileUtilTest.cc\
|
||||||
|
ShaVisitorTest.cc\
|
||||||
|
PeerMessageUtilTest.cc\
|
||||||
|
DefaultDiskWriterTest.cc\
|
||||||
|
MultiDiskAdaptorTest.cc\
|
||||||
|
Xml2MetalinkProcessorTest.cc\
|
||||||
|
MetalinkerTest.cc\
|
||||||
|
MetalinkEntryTest.cc\
|
||||||
|
FeatureConfigTest.cc\
|
||||||
|
ShareRatioSeedCriteriaTest.cc\
|
||||||
|
TimeSeedCriteriaTest.cc\
|
||||||
|
SpeedCalcTest.cc\
|
||||||
|
DefaultPeerListProcessorTest.cc\
|
||||||
|
AnnounceListTest.cc\
|
||||||
|
TrackerWatcherCommandTest.cc\
|
||||||
|
DefaultBtContextTest.cc\
|
||||||
|
DefaultPieceStorageTest.cc\
|
||||||
|
DefaultBtAnnounceTest.cc\
|
||||||
|
BtRegistryTest.cc\
|
||||||
|
DefaultBtMessageDispatcherTest.cc\
|
||||||
|
MockPeerStorage.h\
|
||||||
|
DefaultBtRequestFactoryTest.cc\
|
||||||
|
BtAllowedFastMessageTest.cc\
|
||||||
|
BtBitfieldMessageTest.cc\
|
||||||
|
BtCancelMessageTest.cc\
|
||||||
|
BtChokeMessageTest.cc\
|
||||||
|
BtHaveAllMessageTest.cc\
|
||||||
|
BtHaveMessageTest.cc\
|
||||||
|
BtHaveNoneMessageTest.cc\
|
||||||
|
BtInterestedMessageTest.cc\
|
||||||
|
BtKeepAliveMessageTest.cc\
|
||||||
|
BtNotInterestedMessageTest.cc\
|
||||||
|
BtPieceMessageTest.cc\
|
||||||
|
BtPortMessageTest.cc\
|
||||||
|
BtRejectMessageTest.cc\
|
||||||
|
BtRequestMessageTest.cc\
|
||||||
|
BtSuggestPieceMessageTest.cc\
|
||||||
|
BtUnchokeMessageTest.cc\
|
||||||
|
BtHandshakeMessageTest.cc\
|
||||||
|
MockBtMessageDispatcher.h\
|
||||||
|
FixedNumberRandomizer.h\
|
||||||
|
MockBtMessageFactory.h\
|
||||||
|
MockBtMessage.h\
|
||||||
|
ConsoleFileAllocationMonitorTest.cc\
|
||||||
|
ChunkChecksumValidatorTest.cc
|
||||||
|
|
||||||
# UriFileListParserTest.cc
|
|
||||||
# PeerTest.cc\
|
|
||||||
# DefaultPeerStorageTest.cc\
|
|
||||||
# RequestFactoryTest.cc\
|
|
||||||
# NetrcAuthResolverTest.cc\
|
|
||||||
# DefaultAuthResolverTest.cc\
|
|
||||||
# RequestTest.cc\
|
|
||||||
# HttpRequestTest.cc\
|
|
||||||
# UtilTest.cc\
|
|
||||||
# OptionHandlerTest.cc\
|
|
||||||
# SegmentManTest.cc\
|
|
||||||
# BitfieldManTest.cc\
|
|
||||||
# GlowFileAllocatorTest.cc\
|
|
||||||
# NetrcTest.cc\
|
|
||||||
# SingletonHolderTest.cc\
|
|
||||||
# HttpHeaderTest.cc\
|
|
||||||
# HttpResponseTest.cc\
|
|
||||||
# SharedHandleTest.cc\
|
|
||||||
# ChunkedEncodingTest.cc\
|
|
||||||
# FileTest.cc\
|
|
||||||
# OptionTest.cc\
|
|
||||||
# Base64Test.cc\
|
|
||||||
# CookieBoxTest.cc\
|
|
||||||
# DataTest.cc\
|
|
||||||
# DictionaryTest.cc\
|
|
||||||
# ListTest.cc\
|
|
||||||
# MetaFileUtilTest.cc\
|
|
||||||
# ShaVisitorTest.cc\
|
|
||||||
# PeerMessageUtilTest.cc\
|
|
||||||
# DefaultDiskWriterTest.cc\
|
|
||||||
# MultiDiskAdaptorTest.cc\
|
|
||||||
# Xml2MetalinkProcessorTest.cc\
|
|
||||||
# MetalinkerTest.cc\
|
|
||||||
# MetalinkEntryTest.cc\
|
|
||||||
# FeatureConfigTest.cc\
|
|
||||||
# ShareRatioSeedCriteriaTest.cc\
|
|
||||||
# TimeSeedCriteriaTest.cc\
|
|
||||||
# SpeedCalcTest.cc\
|
|
||||||
# DefaultPeerListProcessorTest.cc\
|
|
||||||
# AnnounceListTest.cc\
|
|
||||||
# TrackerWatcherCommandTest.cc\
|
|
||||||
# DefaultBtContextTest.cc\
|
|
||||||
# DefaultPieceStorageTest.cc\
|
|
||||||
# DefaultBtAnnounceTest.cc\
|
|
||||||
# BtRegistryTest.cc\
|
|
||||||
# DefaultBtMessageDispatcherTest.cc\
|
|
||||||
# MockPeerStorage.h\
|
|
||||||
# DefaultBtRequestFactoryTest.cc\
|
|
||||||
# BtAllowedFastMessageTest.cc\
|
|
||||||
# BtBitfieldMessageTest.cc\
|
|
||||||
# BtCancelMessageTest.cc\
|
|
||||||
# BtChokeMessageTest.cc\
|
|
||||||
# BtHaveAllMessageTest.cc\
|
|
||||||
# BtHaveMessageTest.cc\
|
|
||||||
# BtHaveNoneMessageTest.cc\
|
|
||||||
# BtInterestedMessageTest.cc\
|
|
||||||
# BtKeepAliveMessageTest.cc\
|
|
||||||
# BtNotInterestedMessageTest.cc\
|
|
||||||
# BtPieceMessageTest.cc\
|
|
||||||
# BtPortMessageTest.cc\
|
|
||||||
# BtRejectMessageTest.cc\
|
|
||||||
# BtRequestMessageTest.cc\
|
|
||||||
# BtSuggestPieceMessageTest.cc\
|
|
||||||
# BtUnchokeMessageTest.cc\
|
|
||||||
# BtHandshakeMessageTest.cc\
|
|
||||||
# MockBtMessageDispatcher.h\
|
|
||||||
# FixedNumberRandomizer.h\
|
|
||||||
# MockBtMessageFactory.h\
|
|
||||||
# MockBtMessage.h\
|
|
||||||
# ConsoleFileAllocationMonitorTest.cc\
|
|
||||||
# ChunkChecksumValidatorTest.cc
|
|
||||||
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
#aria2c_CXXFLAGS = ${CPPUNIT_CFLAGS} -I../src -I../lib -Wall -D_FILE_OFFSET_BITS=64
|
||||||
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
#aria2c_LDFLAGS = ${CPPUNIT_LIBS}
|
||||||
aria2c_LDADD = ../src/libaria2c.a\
|
aria2c_LDADD = ../src/libaria2c.a\
|
||||||
|
@ -354,7 +401,74 @@ distclean-compile:
|
||||||
-rm -f *.tab.c
|
-rm -f *.tab.c
|
||||||
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AnnounceListTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Base64Test.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitfieldManTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtAllowedFastMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtBitfieldMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtCancelMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtChokeMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHandshakeMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHaveAllMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHaveMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtHaveNoneMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtInterestedMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtKeepAliveMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtNotInterestedMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtPieceMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtPortMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRegistryTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRejectMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRequestMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtSuggestPieceMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtUnchokeMessageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkChecksumValidatorTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkedEncodingTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConsoleFileAllocationMonitorTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieBoxTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DataTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultAuthResolverTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtAnnounceTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtContextTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtMessageDispatcherTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultBtRequestFactoryTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultDiskWriterTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultPeerListProcessorTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultPeerStorageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefaultPieceStorageTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DictionaryTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FeatureConfigTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GlowFileAllocatorTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpHeaderTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpRequestTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HttpResponseTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChecksumValidatorTest.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChunkChecksumValidatorTest.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IteratableChunkChecksumValidatorTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ListTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetaFileUtilTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkEntryTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MetalinkerTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultiDiskAdaptorTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NetrcAuthResolverTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NetrcTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OptionHandlerTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OptionTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerMessageUtilTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeerTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestFactoryTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SegmentManTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ShaVisitorTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ShareRatioSeedCriteriaTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SharedHandleTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SingletonHolderTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SpeedCalcTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeSeedCriteriaTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerWatcherCommandTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UriFileListParserTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UtilTest.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xml2MetalinkProcessorTest.Po@am__quote@
|
||||||
|
|
||||||
.cc.o:
|
.cc.o:
|
||||||
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||||
|
|
|
@ -21,6 +21,11 @@ public:
|
||||||
copy(peers.begin(), peers.end(), back_inserter(this->peers));
|
copy(peers.begin(), peers.end(), back_inserter(this->peers));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool addIncomingPeer(const PeerHandle& peer)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual const Peers& getPeers() {
|
virtual const Peers& getPeers() {
|
||||||
return peers;
|
return peers;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +49,10 @@ public:
|
||||||
void setStat(const TransferStat& stat) {
|
void setStat(const TransferStat& stat) {
|
||||||
this->stat = stat;
|
this->stat = stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void returnPeer(const PeerHandle& peer)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<MockPeerStorage> MockPeerStorageHandle;
|
typedef SharedHandle<MockPeerStorage> MockPeerStorageHandle;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "DefaultPeerStorage.h"
|
#include "DefaultPeerStorage.h"
|
||||||
#include "BtRegistry.h"
|
#include "BtRegistry.h"
|
||||||
#include "RequestFactory.h"
|
#include "RequestFactory.h"
|
||||||
|
#include "CUIDCounter.h"
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -31,7 +32,11 @@ public:
|
||||||
RequestFactorySingletonHolder::instance(requestFactory);
|
RequestFactorySingletonHolder::instance(requestFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUp() {}
|
void setUp()
|
||||||
|
{
|
||||||
|
CUIDCounterHandle counter = new CUIDCounter();
|
||||||
|
CUIDCounterSingletonHolder::instance(counter);
|
||||||
|
}
|
||||||
|
|
||||||
void testCreateCommand();
|
void testCreateCommand();
|
||||||
};
|
};
|
||||||
|
@ -60,10 +65,7 @@ void TrackerWatcherCommandTest::testCreateCommand() {
|
||||||
BtRegistry::registerBtAnnounce(btContext->getInfoHashAsString(), btAnnounce);
|
BtRegistry::registerBtAnnounce(btContext->getInfoHashAsString(), btAnnounce);
|
||||||
TorrentConsoleDownloadEngine* te = new TorrentConsoleDownloadEngine();
|
TorrentConsoleDownloadEngine* te = new TorrentConsoleDownloadEngine();
|
||||||
te->option = op;
|
te->option = op;
|
||||||
te->segmentMan = new SegmentMan();
|
te->_requestGroupMan = new RequestGroupMan();
|
||||||
te->segmentMan->option = op;
|
|
||||||
ByteArrayDiskWriter* byteArrayDiskWriter = new ByteArrayDiskWriter();
|
|
||||||
te->segmentMan->diskWriter = byteArrayDiskWriter;
|
|
||||||
|
|
||||||
TrackerWatcherCommand command(1, te, btContext);
|
TrackerWatcherCommand command(1, te, btContext);
|
||||||
|
|
||||||
|
@ -72,7 +74,7 @@ void TrackerWatcherCommandTest::testCreateCommand() {
|
||||||
|
|
||||||
btAnnounce->announceSuccess();
|
btAnnounce->announceSuccess();
|
||||||
btAnnounce->resetAnnounce();
|
btAnnounce->resetAnnounce();
|
||||||
te->segmentMan->init();
|
te->_requestGroupMan = new RequestGroupMan();
|
||||||
|
|
||||||
btRuntime->setHalt(true);
|
btRuntime->setHalt(true);
|
||||||
|
|
||||||
|
@ -81,7 +83,7 @@ void TrackerWatcherCommandTest::testCreateCommand() {
|
||||||
|
|
||||||
btAnnounce->announceSuccess();
|
btAnnounce->announceSuccess();
|
||||||
btAnnounce->resetAnnounce();
|
btAnnounce->resetAnnounce();
|
||||||
te->segmentMan->init();
|
te->_requestGroupMan = new RequestGroupMan();
|
||||||
|
|
||||||
CPPUNIT_ASSERT(btAnnounce->noMoreAnnounce());
|
CPPUNIT_ASSERT(btAnnounce->noMoreAnnounce());
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#include "UriFileListParser.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "Util.h"
|
||||||
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class UriFileListParserTest : public CppUnit::TestFixture {
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE(UriFileListParserTest);
|
||||||
|
CPPUNIT_TEST(testHasNext);
|
||||||
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setUp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void testHasNext();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CPPUNIT_TEST_SUITE_REGISTRATION( UriFileListParserTest );
|
||||||
|
|
||||||
|
string list2String(const Strings& src)
|
||||||
|
{
|
||||||
|
ostringstream strm;
|
||||||
|
copy(src.begin(), src.end(), ostream_iterator<string>(strm, " "));
|
||||||
|
return Util::trim(strm.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void UriFileListParserTest::testHasNext()
|
||||||
|
{
|
||||||
|
UriFileListParser flp("filelist1.txt");
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT(flp.hasNext());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("http://localhost/index.html http://localhost2/index.html"), list2String(flp.next()));
|
||||||
|
CPPUNIT_ASSERT(flp.hasNext());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string("ftp://localhost/aria2.tar.bz2"),
|
||||||
|
list2String(flp.next()));
|
||||||
|
CPPUNIT_ASSERT(flp.hasNext());
|
||||||
|
CPPUNIT_ASSERT_EQUAL(string(""),
|
||||||
|
list2String(flp.next()));
|
||||||
|
CPPUNIT_ASSERT(!flp.hasNext());
|
||||||
|
}
|
|
@ -38,8 +38,8 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
||||||
CPPUNIT_ASSERT_EQUAL(string("en-US"), entry1->language);
|
CPPUNIT_ASSERT_EQUAL(string("en-US"), entry1->language);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("Linux-x86"), entry1->os);
|
CPPUNIT_ASSERT_EQUAL(string("Linux-x86"), entry1->os);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("a96cf3f0266b91d87d5124cf94326422800b627d"),
|
CPPUNIT_ASSERT_EQUAL(string("a96cf3f0266b91d87d5124cf94326422800b627d"),
|
||||||
entry1->checksum.getMessageDigest());
|
entry1->checksum->getMessageDigest());
|
||||||
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry1->checksum.getDigestAlgo());
|
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry1->checksum->getDigestAlgo());
|
||||||
|
|
||||||
MetalinkResources::iterator resourceItr1 = entry1->resources.begin();
|
MetalinkResources::iterator resourceItr1 = entry1->resources.begin();
|
||||||
MetalinkResourceHandle resource1 = *resourceItr1;
|
MetalinkResourceHandle resource1 = *resourceItr1;
|
||||||
|
@ -65,7 +65,7 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
||||||
CPPUNIT_ASSERT_EQUAL(string("ja-JP"), entry2->language);
|
CPPUNIT_ASSERT_EQUAL(string("ja-JP"), entry2->language);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
CPPUNIT_ASSERT_EQUAL(string("Linux-m68k"), entry2->os);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
CPPUNIT_ASSERT_EQUAL(string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"),
|
||||||
entry2->checksum.getMessageDigest());
|
entry2->checksum->getMessageDigest());
|
||||||
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->pieceHashes.size());
|
CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->pieceHashes.size());
|
||||||
CPPUNIT_ASSERT_EQUAL(262144, entry2->chunkChecksum->pieceLength);
|
CPPUNIT_ASSERT_EQUAL(262144, entry2->chunkChecksum->pieceLength);
|
||||||
CPPUNIT_ASSERT_EQUAL(string("179463a88d79cbf0b1923991708aead914f26142"),
|
CPPUNIT_ASSERT_EQUAL(string("179463a88d79cbf0b1923991708aead914f26142"),
|
||||||
|
@ -73,7 +73,7 @@ void Xml2MetalinkProcessorTest::testParseFile() {
|
||||||
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
CPPUNIT_ASSERT_EQUAL(string("fecf8bc9a1647505fe16746f94e97a477597dbf3"),
|
||||||
entry2->chunkChecksum->pieceHashes.at(1));
|
entry2->chunkChecksum->pieceHashes.at(1));
|
||||||
|
|
||||||
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum.getDigestAlgo());
|
CPPUNIT_ASSERT(DIGEST_ALGO_SHA1 == entry2->checksum->getDigestAlgo());
|
||||||
} catch(Exception* e) {
|
} catch(Exception* e) {
|
||||||
CPPUNIT_FAIL(e->getMsg());
|
CPPUNIT_FAIL(e->getMsg());
|
||||||
delete e;
|
delete e;
|
||||||
|
|
Loading…
Reference in New Issue