mirror of https://github.com/aria2/aria2
2010-06-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made protected member variable private. Added accessor funcs. * src/BtCheckIntegrityEntry.cc * src/BtFileAllocationEntry.cc * src/CheckIntegrityEntry.cc * src/CheckIntegrityEntry.h * src/ChecksumCheckIntegrityEntry.cc * src/FileAllocationEntry.cc * src/PieceHashCheckIntegrityEntry.cc * src/RequestGroupEntry.h * src/StreamCheckIntegrityEntry.cc * src/StreamFileAllocationEntry.ccpull/1/head
parent
f114c89096
commit
a68b29a31a
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2010-06-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Made protected member variable private. Added accessor funcs.
|
||||
* src/BtCheckIntegrityEntry.cc
|
||||
* src/BtFileAllocationEntry.cc
|
||||
* src/CheckIntegrityEntry.cc
|
||||
* src/CheckIntegrityEntry.h
|
||||
* src/ChecksumCheckIntegrityEntry.cc
|
||||
* src/FileAllocationEntry.cc
|
||||
* src/PieceHashCheckIntegrityEntry.cc
|
||||
* src/RequestGroupEntry.h
|
||||
* src/StreamCheckIntegrityEntry.cc
|
||||
* src/StreamFileAllocationEntry.cc
|
||||
|
||||
2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Made protected member variable private. Added accessor funcs.
|
||||
|
|
|
@ -55,7 +55,7 @@ void BtCheckIntegrityEntry::onDownloadIncomplete
|
|||
(std::vector<Command*>& commands, DownloadEngine* e)
|
||||
{
|
||||
const SharedHandle<DiskAdaptor>& diskAdaptor =
|
||||
_requestGroup->getPieceStorage()->getDiskAdaptor();
|
||||
getRequestGroup()->getPieceStorage()->getDiskAdaptor();
|
||||
if(diskAdaptor->isReadOnlyEnabled()) {
|
||||
// Now reopen DiskAdaptor with read only disabled.
|
||||
diskAdaptor->closeFile();
|
||||
|
@ -63,7 +63,7 @@ void BtCheckIntegrityEntry::onDownloadIncomplete
|
|||
diskAdaptor->openFile();
|
||||
}
|
||||
SharedHandle<BtFileAllocationEntry> entry
|
||||
(new BtFileAllocationEntry(_requestGroup));
|
||||
(new BtFileAllocationEntry(getRequestGroup()));
|
||||
proceedFileAllocation(commands, entry, e);
|
||||
}
|
||||
|
||||
|
@ -74,9 +74,9 @@ void BtCheckIntegrityEntry::onDownloadFinished
|
|||
// are valid, then aira2 goes to seeding mode. Sometimes it is better
|
||||
// to exit rather than doing seeding. So, it would be good to toggle this
|
||||
// behavior.
|
||||
if(_requestGroup->getOption()->getAsBool(PREF_BT_HASH_CHECK_SEED)) {
|
||||
if(getRequestGroup()->getOption()->getAsBool(PREF_BT_HASH_CHECK_SEED)) {
|
||||
SharedHandle<BtFileAllocationEntry> entry
|
||||
(new BtFileAllocationEntry(_requestGroup));
|
||||
(new BtFileAllocationEntry(getRequestGroup()));
|
||||
proceedFileAllocation(commands, entry, e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,15 @@ BtFileAllocationEntry::~BtFileAllocationEntry() {}
|
|||
void BtFileAllocationEntry::prepareForNextAction
|
||||
(std::vector<Command*>& commands, DownloadEngine* e)
|
||||
{
|
||||
BtSetup().setup(commands, _requestGroup, e, _requestGroup->getOption().get());
|
||||
if(!_requestGroup->downloadFinished()) {
|
||||
_requestGroup->getDownloadContext()->resetDownloadStartTime();
|
||||
BtSetup().setup(commands, getRequestGroup(), e,
|
||||
getRequestGroup()->getOption().get());
|
||||
if(!getRequestGroup()->downloadFinished()) {
|
||||
getRequestGroup()->getDownloadContext()->resetDownloadStartTime();
|
||||
const std::vector<SharedHandle<FileEntry> >& fileEntries =
|
||||
_requestGroup->getDownloadContext()->getFileEntries();
|
||||
if(isUriSuppliedForRequsetFileEntry(fileEntries.begin(), fileEntries.end())) {
|
||||
_requestGroup->createNextCommandWithAdj(commands, e, 0);
|
||||
getRequestGroup()->getDownloadContext()->getFileEntries();
|
||||
if(isUriSuppliedForRequsetFileEntry
|
||||
(fileEntries.begin(), fileEntries.end())) {
|
||||
getRequestGroup()->createNextCommandWithAdj(commands, e, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ bool CheckIntegrityEntry::finished()
|
|||
|
||||
void CheckIntegrityEntry::cutTrailingGarbage()
|
||||
{
|
||||
_requestGroup->getPieceStorage()->getDiskAdaptor()->cutTrailingGarbage();
|
||||
getRequestGroup()->getPieceStorage()->getDiskAdaptor()->cutTrailingGarbage();
|
||||
}
|
||||
|
||||
void CheckIntegrityEntry::proceedFileAllocation
|
||||
|
@ -92,16 +92,21 @@ void CheckIntegrityEntry::proceedFileAllocation
|
|||
const SharedHandle<FileAllocationEntry>& entry,
|
||||
DownloadEngine* e)
|
||||
{
|
||||
if(_requestGroup->needsFileAllocation()) {
|
||||
if(getRequestGroup()->needsFileAllocation()) {
|
||||
e->getFileAllocationMan()->pushEntry(entry);
|
||||
} else {
|
||||
entry->prepareForNextAction(commands, e);
|
||||
}
|
||||
// Disable directIO when fallocation() is going to be used.
|
||||
if(_requestGroup->getOption()->get(PREF_FILE_ALLOCATION) == V_FALLOC) {
|
||||
if(getRequestGroup()->getOption()->get(PREF_FILE_ALLOCATION) == V_FALLOC) {
|
||||
entry->disableDirectIO();
|
||||
}
|
||||
}
|
||||
|
||||
void CheckIntegrityEntry::setValidator
|
||||
(const SharedHandle<IteratableValidator>& validator)
|
||||
{
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -48,8 +48,10 @@ class FileAllocationEntry;
|
|||
|
||||
class CheckIntegrityEntry : public RequestGroupEntry,
|
||||
public ProgressAwareEntry {
|
||||
protected:
|
||||
private:
|
||||
SharedHandle<IteratableValidator> _validator;
|
||||
protected:
|
||||
void setValidator(const SharedHandle<IteratableValidator>& validator);
|
||||
|
||||
void proceedFileAllocation(std::vector<Command*>& commands,
|
||||
const SharedHandle<FileAllocationEntry>& entry,
|
||||
|
|
|
@ -52,16 +52,17 @@ ChecksumCheckIntegrityEntry::~ChecksumCheckIntegrityEntry() {}
|
|||
|
||||
bool ChecksumCheckIntegrityEntry::isValidationReady()
|
||||
{
|
||||
return !_requestGroup->getDownloadContext()->getChecksum().empty() &&
|
||||
!_requestGroup->getDownloadContext()->getChecksumHashAlgo().empty();
|
||||
return !getRequestGroup()->getDownloadContext()->getChecksum().empty() &&
|
||||
!getRequestGroup()->getDownloadContext()->getChecksumHashAlgo().empty();
|
||||
}
|
||||
|
||||
void ChecksumCheckIntegrityEntry::initValidator()
|
||||
{
|
||||
_validator.reset(new IteratableChecksumValidator
|
||||
(_requestGroup->getDownloadContext(),
|
||||
_requestGroup->getPieceStorage()));
|
||||
_validator->init();
|
||||
SharedHandle<IteratableChecksumValidator> validator
|
||||
(new IteratableChecksumValidator(getRequestGroup()->getDownloadContext(),
|
||||
getRequestGroup()->getPieceStorage()));
|
||||
validator->init();
|
||||
setValidator(validator);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -49,12 +49,12 @@ FileAllocationEntry::FileAllocationEntry(RequestGroup* requestGroup, Command* ne
|
|||
RequestGroupEntry(requestGroup, nextCommand),
|
||||
_fileAllocationIterator(requestGroup->getPieceStorage()->getDiskAdaptor()->fileAllocationIterator())
|
||||
{
|
||||
_requestGroup->getPieceStorage()->getDiskAdaptor()->enableDirectIO();
|
||||
getRequestGroup()->getPieceStorage()->getDiskAdaptor()->enableDirectIO();
|
||||
}
|
||||
|
||||
FileAllocationEntry:: ~FileAllocationEntry()
|
||||
{
|
||||
_requestGroup->getPieceStorage()->getDiskAdaptor()->disableDirectIO();
|
||||
getRequestGroup()->getPieceStorage()->getDiskAdaptor()->disableDirectIO();
|
||||
}
|
||||
|
||||
off_t FileAllocationEntry::getCurrentLength()
|
||||
|
@ -79,7 +79,7 @@ void FileAllocationEntry::allocateChunk()
|
|||
|
||||
void FileAllocationEntry::disableDirectIO()
|
||||
{
|
||||
_requestGroup->getPieceStorage()->getDiskAdaptor()->disableDirectIO();
|
||||
getRequestGroup()->getPieceStorage()->getDiskAdaptor()->disableDirectIO();
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -40,8 +40,9 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
PieceHashCheckIntegrityEntry::PieceHashCheckIntegrityEntry(RequestGroup* requestGroup,
|
||||
Command* nextCommand):
|
||||
PieceHashCheckIntegrityEntry::PieceHashCheckIntegrityEntry
|
||||
(RequestGroup* requestGroup,
|
||||
Command* nextCommand):
|
||||
CheckIntegrityEntry(requestGroup, nextCommand) {}
|
||||
|
||||
PieceHashCheckIntegrityEntry::~PieceHashCheckIntegrityEntry() {}
|
||||
|
@ -49,7 +50,7 @@ PieceHashCheckIntegrityEntry::~PieceHashCheckIntegrityEntry() {}
|
|||
bool PieceHashCheckIntegrityEntry::isValidationReady()
|
||||
{
|
||||
const SharedHandle<DownloadContext>& dctx =
|
||||
_requestGroup->getDownloadContext();
|
||||
getRequestGroup()->getDownloadContext();
|
||||
return !dctx->getPieceHashAlgo().empty() &&
|
||||
dctx->getPieceHashes().size() > 0 &&
|
||||
dctx->getPieceHashes().size() == dctx->getNumPieces();
|
||||
|
@ -59,10 +60,11 @@ void PieceHashCheckIntegrityEntry::initValidator()
|
|||
{
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
IteratableChunkChecksumValidatorHandle validator
|
||||
(new IteratableChunkChecksumValidator(_requestGroup->getDownloadContext(),
|
||||
_requestGroup->getPieceStorage()));
|
||||
(new IteratableChunkChecksumValidator
|
||||
(getRequestGroup()->getDownloadContext(),
|
||||
getRequestGroup()->getPieceStorage()));
|
||||
validator->init();
|
||||
_validator = validator;
|
||||
setValidator(validator);
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class RequestGroup;
|
|||
class Command;
|
||||
|
||||
class RequestGroupEntry {
|
||||
protected:
|
||||
private:
|
||||
RequestGroup* _requestGroup;
|
||||
Command* _nextCommand;
|
||||
public:
|
||||
|
|
|
@ -53,7 +53,7 @@ void StreamCheckIntegrityEntry::onDownloadIncomplete
|
|||
(std::vector<Command*>& commands, DownloadEngine* e)
|
||||
{
|
||||
SharedHandle<FileAllocationEntry> entry
|
||||
(new StreamFileAllocationEntry(_requestGroup, popNextCommand()));
|
||||
(new StreamFileAllocationEntry(getRequestGroup(), popNextCommand()));
|
||||
proceedFileAllocation(commands, entry, e);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,16 +59,16 @@ void StreamFileAllocationEntry::prepareForNextAction
|
|||
(std::vector<Command*>& commands,
|
||||
DownloadEngine* e)
|
||||
{
|
||||
_requestGroup->getDownloadContext()->resetDownloadStartTime();
|
||||
if(_nextCommand) {
|
||||
getRequestGroup()->getDownloadContext()->resetDownloadStartTime();
|
||||
if(getNextCommand()) {
|
||||
// give _nextCommand a chance to execute in the next execution loop.
|
||||
_nextCommand->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||
getNextCommand()->setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||
e->setNoWait(true);
|
||||
commands.push_back(popNextCommand());
|
||||
// try remaining uris
|
||||
_requestGroup->createNextCommandWithAdj(commands, e, -1);
|
||||
getRequestGroup()->createNextCommandWithAdj(commands, e, -1);
|
||||
} else {
|
||||
_requestGroup->createNextCommandWithAdj(commands, e, 0);
|
||||
getRequestGroup()->createNextCommandWithAdj(commands, e, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue