summaryrefslogtreecommitdiff
path: root/src/DownloadCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-05-14 15:18:59 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-05-14 15:18:59 +0000
commit83465ff83d76e7748747b3cfcb30f902aa8b8a78 (patch)
tree2b9230352caf8d696176eeee5fdd774f0da6b047 /src/DownloadCommand.cc
parentb305edd7c5ccd2c0ca78ecb3e92f9840065b5c31 (diff)
2010-05-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Store both whole checksum and piece hash in metalink file. Dispatch whole checksum verification only when piece hash is not set. * src/DownloadCommand.cc * src/Metalink2RequestGroup.cc * test/Metalink2RequestGroupTest.cc
Diffstat (limited to 'src/DownloadCommand.cc')
-rw-r--r--src/DownloadCommand.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc
index 226720d8..256b7c94 100644
--- a/src/DownloadCommand.cc
+++ b/src/DownloadCommand.cc
@@ -210,7 +210,7 @@ bool DownloadCommand::executeInternal() {
#ifdef ENABLE_MESSAGE_DIGEST
{
- std::string expectedPieceHash =
+ const std::string& expectedPieceHash =
_requestGroup->getDownloadContext()->getPieceHash(segment->getIndex());
if(_pieceHashValidationEnabled && !expectedPieceHash.empty()) {
if(segment->isHashCalculated()) {
@@ -271,26 +271,29 @@ void DownloadCommand::checkLowestDownloadSpeed() const
bool DownloadCommand::prepareForNextSegment() {
if(_requestGroup->downloadFinished()) {
+ const SharedHandle<DownloadContext>& dctx =
+ _requestGroup->getDownloadContext();
// Remove in-flight request here.
_fileEntry->poolRequest(req);
// If this is a single file download, and file size becomes known
// just after downloading, set total length to FileEntry object
// here.
- if(_requestGroup->getDownloadContext()->getFileEntries().size() == 1) {
- const SharedHandle<FileEntry>& fileEntry =
- _requestGroup->getDownloadContext()->getFirstFileEntry();
+ if(dctx->getFileEntries().size() == 1) {
+ const SharedHandle<FileEntry>& fileEntry = dctx->getFirstFileEntry();
if(fileEntry->getLength() == 0) {
fileEntry->setLength
(_requestGroup->getPieceStorage()->getCompletedLength());
}
}
#ifdef ENABLE_MESSAGE_DIGEST
- SharedHandle<CheckIntegrityEntry> entry
- (new ChecksumCheckIntegrityEntry(_requestGroup));
- if(entry->isValidationReady()) {
- entry->initValidator();
- // TODO do we need cuttrailinggarbage here?
- e->_checkIntegrityMan->pushEntry(entry);
+ if(dctx->getPieceHashAlgo().empty()) {
+ SharedHandle<CheckIntegrityEntry> entry
+ (new ChecksumCheckIntegrityEntry(_requestGroup));
+ if(entry->isValidationReady()) {
+ entry->initValidator();
+ // TODO do we need cuttrailinggarbage here?
+ e->_checkIntegrityMan->pushEntry(entry);
+ }
}
// Following 2lines are needed for DownloadEngine to detect
// completed RequestGroups without 1sec delay.