summaryrefslogtreecommitdiff
path: root/src/CheckIntegrityCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
commit048a2cf59737f761876e81a77e8d064c45c752d7 (patch)
tree65c9d5498aafe6a8c8e640ddfcc43c7013504d0d /src/CheckIntegrityCommand.cc
parente26bbbb9eee140ba24402fe872a752b42f0077de (diff)
2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented BitTorrent/http/ftp integrated download. I've rewritten lots of files and now some headers have forward class declarations to reduce compile time. The implementation is extremely alpha stage, I recommend to use this for testing purpose only.
Diffstat (limited to 'src/CheckIntegrityCommand.cc')
-rw-r--r--src/CheckIntegrityCommand.cc30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/CheckIntegrityCommand.cc b/src/CheckIntegrityCommand.cc
index 5b1231cd..a2d4aad1 100644
--- a/src/CheckIntegrityCommand.cc
+++ b/src/CheckIntegrityCommand.cc
@@ -33,6 +33,9 @@
*/
/* copyright --> */
#include "CheckIntegrityCommand.h"
+#include "CheckIntegrityMan.h"
+#include "CheckIntegrityEntry.h"
+#include "RequestGroup.h"
#include "FileAllocationEntry.h"
#include "InitiateConnectionCommandFactory.h"
#include "DlAbortEx.h"
@@ -40,7 +43,7 @@
#include "DownloadCommand.h"
#include "prefs.h"
-CheckIntegrityCommand::CheckIntegrityCommand(int cuid, RequestGroup* requestGroup, DownloadEngine* e, const CheckIntegrityEntryHandle& entry):
+CheckIntegrityCommand::CheckIntegrityCommand(int32_t cuid, RequestGroup* requestGroup, DownloadEngine* e, const CheckIntegrityEntryHandle& entry):
RealtimeCommand(cuid, requestGroup, e),
_entry(entry)
{
@@ -54,25 +57,16 @@ CheckIntegrityCommand::~CheckIntegrityCommand()
bool CheckIntegrityCommand::executeInternal()
{
+ if(_requestGroup->isHaltRequested()) {
+ return true;
+ }
_entry->validateChunk();
if(_entry->finished()) {
+ _entry->updatePieceStorage();
if(_requestGroup->downloadFinished()) {
logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, cuid, _requestGroup->getFilePath().c_str());
- return true;
- }
- if(_requestGroup->needsFileAllocation()) {
- FileAllocationEntryHandle entry = new FileAllocationEntry(cuid, _entry->getCurrentRequest(), _requestGroup, _entry->popNextDownloadCommand(), _requestGroup->getExistingFileLength());
- _e->_fileAllocationMan->pushFileAllocationEntry(entry);
} else {
- if(_timer.difference() <= _e->option->getAsInt(PREF_DIRECT_DOWNLOAD_TIMEOUT) &&
- _entry->getNextDownloadCommand()) {
- _e->commands.push_back(_entry->popNextDownloadCommand());
- } else {
- Commands commands = _requestGroup->createNextCommandWithAdj(_e, -1);
- Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, _entry->getCurrentRequest(), _requestGroup, _e);
- commands.push_front(command);
- _e->addCommand(commands);
- }
+ _e->addCommand(_entry->prepareForNextAction(_e));
}
return true;
} else {
@@ -84,12 +78,6 @@ bool CheckIntegrityCommand::executeInternal()
bool CheckIntegrityCommand::handleException(Exception* e)
{
logger->error(MSG_FILE_VALIDATION_FAILURE, 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(_entry->getCurrentLength());
return true;
}