/* */ #include "FileAllocationCommand.h" #include "InitiateConnectionCommandFactory.h" #include "message.h" #include "DownloadCommand.h" #include "prefs.h" bool FileAllocationCommand::executeInternal() { _fileAllocationEntry->allocateChunk(); if(_fileAllocationEntry->finished()) { logger->debug("%d seconds to allocate %lld byte(s)", _timer.difference(), _requestGroup->getTotalLength()); _e->_fileAllocationMan->markCurrentFileAllocationEntryDone(); if(_timer.difference() <= _e->option->getAsInt(PREF_DIRECT_DOWNLOAD_TIMEOUT) && _fileAllocationEntry->getNextDownloadCommand()) { _e->commands.push_back(_fileAllocationEntry->popNextDownloadCommand()); } else { Commands commands = _requestGroup->createNextCommandWithAdj(_e, -1); Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, _fileAllocationEntry->getCurrentRequest(), _requestGroup, _e); commands.push_front(command); _e->addCommand(commands); } 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; }