From 76b9093d09d76b399823e36c83f1289b37ca2624 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 8 Nov 2007 10:59:44 +0000 Subject: [PATCH] 2007-11-08 Tatsuhiro Tsujikawa Changed CheckIntegrityEntry interface so that it can define the action when all the chunk checksums are valid. * src/CheckIntegrityEntry.h * src/StreamCheckIntegrityEntry.{h, cc} * src/BtCheckIntegrityEntry.{h, cc}: Currently,when all the checksums 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. * src/CheckIntegrityCommand.cc * src/AbstractCommand.cc * src/RequestGroup.cc --- ChangeLog | 14 ++++++++++++++ TODO | 5 +++-- src/AbstractCommand.cc | 2 +- src/BtCheckIntegrityEntry.cc | 11 ++++++++++- src/BtCheckIntegrityEntry.h | 4 +++- src/CheckIntegrityCommand.cc | 3 ++- src/CheckIntegrityEntry.h | 4 +++- src/RequestGroup.cc | 2 +- src/StreamCheckIntegrityEntry.cc | 7 ++++++- src/StreamCheckIntegrityEntry.h | 4 +++- 10 files changed, 46 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3c011d35..9e4d5c8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-11-08 Tatsuhiro Tsujikawa + + Changed CheckIntegrityEntry interface so that it can define + the action when all the chunk checksums are valid. + * src/CheckIntegrityEntry.h + * src/StreamCheckIntegrityEntry.{h, cc} + * src/BtCheckIntegrityEntry.{h, cc}: Currently,when all the checksums + 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. + * src/CheckIntegrityCommand.cc + * src/AbstractCommand.cc + * src/RequestGroup.cc + 2007-11-07 Tatsuhiro Tsujikawa Reflect the download length of in-flight pieces. diff --git a/TODO b/TODO index 69069328..94fcdc9e 100644 --- a/TODO +++ b/TODO @@ -47,10 +47,11 @@ * Limit the number of opening file to,say,100 in MultiDiskAdaptor. * Implement the feature to treat http/ftp as auxuality download method for BitTorrent * http-seeding(single and multi-file torrent) +* Use content-type for PostDownloadHandler -- remaining features to be implemented for 0.12.0 release * Reimplement ChecksumCommand(validation using 1 checksum for 1 file) * Implement duplicate download checking in Bt * improve --metalink-location field -* Use content-type for PostDownloadHandler - +* Do not connect a server when before checking file integrity. +* If size and filename is provided(for example, metalink), "HEAD" like behavior is unnecessary. diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 809a5485..70155842 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -425,6 +425,6 @@ void AbstractCommand::prepareForNextAction(Command* nextCommand) } else #endif // ENABLE_MESSAGE_DIGEST { - e->addCommand(entry->prepareForNextAction(e)); + e->addCommand(entry->onDownloadIncomplete(e)); } } diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc index e3ea5676..a115b7c6 100644 --- a/src/BtCheckIntegrityEntry.cc +++ b/src/BtCheckIntegrityEntry.cc @@ -47,7 +47,7 @@ BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup): BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {} -Commands BtCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e) +Commands BtCheckIntegrityEntry::onDownloadIncomplete(DownloadEngine* e) { Commands commands; FileAllocationEntryHandle entry = new BtFileAllocationEntry(_requestGroup); @@ -58,3 +58,12 @@ Commands BtCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e) } return commands; } + +Commands BtCheckIntegrityEntry::onDownloadFinished(DownloadEngine* e) +{ + // TODO Currently,when all the checksums + // 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. + return onDownloadIncomplete(e); +} diff --git a/src/BtCheckIntegrityEntry.h b/src/BtCheckIntegrityEntry.h index 1b5e25cd..18dd589e 100644 --- a/src/BtCheckIntegrityEntry.h +++ b/src/BtCheckIntegrityEntry.h @@ -43,7 +43,9 @@ public: virtual ~BtCheckIntegrityEntry(); - virtual Commands prepareForNextAction(DownloadEngine* e); + virtual Commands onDownloadFinished(DownloadEngine* e); + + virtual Commands onDownloadIncomplete(DownloadEngine* e); }; typedef SharedHandle BtCheckIntegrityEntryHandle; diff --git a/src/CheckIntegrityCommand.cc b/src/CheckIntegrityCommand.cc index a2d4aad1..4aac8de9 100644 --- a/src/CheckIntegrityCommand.cc +++ b/src/CheckIntegrityCommand.cc @@ -65,8 +65,9 @@ bool CheckIntegrityCommand::executeInternal() _entry->updatePieceStorage(); if(_requestGroup->downloadFinished()) { logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str()); + _e->addCommand(_entry->onDownloadFinished(_e)); } else { - _e->addCommand(_entry->prepareForNextAction(_e)); + _e->addCommand(_entry->onDownloadIncomplete(_e)); } return true; } else { diff --git a/src/CheckIntegrityEntry.h b/src/CheckIntegrityEntry.h index e82076d1..a6d0bf1c 100644 --- a/src/CheckIntegrityEntry.h +++ b/src/CheckIntegrityEntry.h @@ -66,7 +66,9 @@ public: void updatePieceStorage(); - virtual Commands prepareForNextAction(DownloadEngine* e) = 0; + virtual Commands onDownloadFinished(DownloadEngine* e) = 0; + + virtual Commands onDownloadIncomplete(DownloadEngine* e) = 0; }; typedef SharedHandle CheckIntegrityEntryHandle; diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 99f8bfc9..21fd5afb 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -214,7 +214,7 @@ Commands RequestGroup::createInitialCommand(DownloadEngine* e) } else #endif // ENABLE_MESSAGE_DIGEST { - commands = entry->prepareForNextAction(e); + commands = entry->onDownloadIncomplete(e); } return commands; } diff --git a/src/StreamCheckIntegrityEntry.cc b/src/StreamCheckIntegrityEntry.cc index 5ebb535c..9cd8dfb4 100644 --- a/src/StreamCheckIntegrityEntry.cc +++ b/src/StreamCheckIntegrityEntry.cc @@ -51,7 +51,7 @@ StreamCheckIntegrityEntry::StreamCheckIntegrityEntry(const RequestHandle& curren StreamCheckIntegrityEntry::~StreamCheckIntegrityEntry() {} -Commands StreamCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e) +Commands StreamCheckIntegrityEntry::onDownloadIncomplete(DownloadEngine* e) { Commands commands; if(_requestGroup->needsFileAllocation()) { @@ -73,3 +73,8 @@ Commands StreamCheckIntegrityEntry::prepareForNextAction(DownloadEngine* e) } return commands; } + +Commands StreamCheckIntegrityEntry::onDownloadFinished(DownloadEngine* e) +{ + return Commands(); +} diff --git a/src/StreamCheckIntegrityEntry.h b/src/StreamCheckIntegrityEntry.h index 7b864962..7608b239 100644 --- a/src/StreamCheckIntegrityEntry.h +++ b/src/StreamCheckIntegrityEntry.h @@ -57,7 +57,9 @@ public: virtual ~StreamCheckIntegrityEntry(); - virtual Commands prepareForNextAction(DownloadEngine* e); + virtual Commands onDownloadFinished(DownloadEngine* e); + + virtual Commands onDownloadIncomplete(DownloadEngine* e); }; typedef SharedHandle StreamCheckIntegrityEntryHandle;