diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-11-08 10:59:44 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2007-11-08 10:59:44 +0000 |
| commit | 76b9093d09d76b399823e36c83f1289b37ca2624 (patch) | |
| tree | 94fb6bb2a008c75b0064327223a7555e2dd8b94f /src | |
| parent | b4f7588ba285a8e33dc07acfa730491285cba18e (diff) | |
2007-11-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/AbstractCommand.cc | 2 | ||||
| -rw-r--r-- | src/BtCheckIntegrityEntry.cc | 11 | ||||
| -rw-r--r-- | src/BtCheckIntegrityEntry.h | 4 | ||||
| -rw-r--r-- | src/CheckIntegrityCommand.cc | 3 | ||||
| -rw-r--r-- | src/CheckIntegrityEntry.h | 4 | ||||
| -rw-r--r-- | src/RequestGroup.cc | 2 | ||||
| -rw-r--r-- | src/StreamCheckIntegrityEntry.cc | 7 | ||||
| -rw-r--r-- | src/StreamCheckIntegrityEntry.h | 4 |
8 files changed, 29 insertions, 8 deletions
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<BtCheckIntegrityEntry> 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<CheckIntegrityEntry> 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<StreamCheckIntegrityEntry> StreamCheckIntegrityEntryHandle; |
