From ccdd5b31a3dfa07cd13d6f7f0f5eaa3d8ff8a61e Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 31 May 2007 15:56:20 +0000 Subject: 2007-06-01 Tatsuhiro Tsujikawa * src/FileAllocationCommand.cc: Derived from RealtimeCommand. * src/CheckIntegrityCommand.cc: Derived from RealtimeCommand. * src/MetalinkEntry.h (checksum): Changed to ChecksumHandle * src/MetalinkRequestInfo.cc (checksum): Changed to ChecksumHandle * src/File.cc (mkdirs): OPEN_MODE -> DIR_OPEN_MODE * src/common.h (DIR_OPEN_MODE): New definition * src/RequestGroup.cc (prepareForNextAction): Added an argument. * src/message.h (MSG_GOOD_CHECKSUM): New definition (MSG_BAD_CHECKSUM): New definition * src/HttpResponseCommand.cc (handleDefaultEncoding): Continue download sequence in new non-segmented download. * src/FileAllocationEntry.h (_nextDownloadCommand): New variable. * src/DownloadCommand.cc (prepareForNextSegment): Create ChecksumCommand if checksum is available. * src/RealtimeCommand.h, src/RealtimeCommand.cc: New class. * src/IteratableChecksumValidator.h, src/IteratableChecksumValidator.cc: New class. * src/ChecksumCommand.h, src/ChecksumCommand.cc: New class. --- src/HttpResponseCommand.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/HttpResponseCommand.cc') diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index 1ba9b680..f3dcfe09 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -91,7 +91,7 @@ bool HttpResponseCommand::executeInternal() _requestGroup->validateFilename(httpResponse->determinFilename()); _requestGroup->validateTotalLength(httpResponse->getEntityLength()); - createHttpDownloadCommand(httpResponse); + e->commands.push_back(createHttpDownloadCommand(httpResponse)); return true; } else { // TODO validate totalsize against hintTotalSize if it is provided. @@ -136,8 +136,13 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe } } + DownloadCommand* command = 0; + File file(_requestGroup->getFilePath()); + if(_requestGroup->getRemainingUris().empty() && !file.exists()) { + command = createHttpDownloadCommand(httpResponse); + } _requestGroup->loadAndOpenFile(); - _requestGroup->prepareForNextAction(cuid, req, e); + _requestGroup->prepareForNextAction(cuid, req, e, command); e->noWait = true; return true; } @@ -157,11 +162,11 @@ bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResp req->setKeepAlive(false); segment = _requestGroup->getSegmentMan()->getSegment(cuid); _requestGroup->getSegmentMan()->diskWriter->initAndOpenFile(_requestGroup->getSegmentMan()->getFilePath()); - createHttpDownloadCommand(httpResponse); + e->commands.push_back(createHttpDownloadCommand(httpResponse)); return true; } -void HttpResponseCommand::createHttpDownloadCommand(const HttpResponseHandle& httpResponse) +HttpDownloadCommand* HttpResponseCommand::createHttpDownloadCommand(const HttpResponseHandle& httpResponse) { TransferEncodingHandle enc = 0; if(httpResponse->isTransferEncodingSpecified()) { @@ -179,7 +184,7 @@ void HttpResponseCommand::createHttpDownloadCommand(const HttpResponseHandle& ht command->setLowestDownloadSpeedLimit(e->option->getAsInt(PREF_LOWEST_SPEED_LIMIT)); command->setTransferDecoder(enc); - e->commands.push_back(command); + return command; } bool HttpResponseCommand::doTorrentStuff(const HttpResponseHandle& httpResponse) @@ -195,6 +200,6 @@ bool HttpResponseCommand::doTorrentStuff(const HttpResponseHandle& httpResponse) _requestGroup->getSegmentMan()->isSplittable = false; _requestGroup->getSegmentMan()->downloadStarted = true; _requestGroup->getSegmentMan()->diskWriter->initAndOpenFile("/tmp/aria2"+Util::itos((int32_t)getpid())); - createHttpDownloadCommand(httpResponse); + e->commands.push_back(createHttpDownloadCommand(httpResponse)); return true; } -- cgit