summaryrefslogtreecommitdiff
path: root/src/HttpResponseCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-10 11:52:16 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-09-10 11:52:16 +0000
commit32e3ebf112076a3185960e5cb794e760d6c4a1fe (patch)
treee98dd3d9437a5214277029267b8d606eb1ca05af /src/HttpResponseCommand.cc
parent6e7dd1650e4f85a8fc7b942e5310f3c9c6fed626 (diff)
2010-09-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Check hash(hash for entire file, not piece hash) if --check-integrity option is given and file is downloaded(determined by file length). If it fails, re-download file. * src/AbstractCommand.cc * src/ChecksumCheckIntegrityEntry.cc * src/ChecksumCheckIntegrityEntry.h * src/FtpNegotiationCommand.cc * src/HttpResponseCommand.cc * src/RequestGroup.cc
Diffstat (limited to 'src/HttpResponseCommand.cc')
-rw-r--r--src/HttpResponseCommand.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc
index 9f865d77..74b1c659 100644
--- a/src/HttpResponseCommand.cc
+++ b/src/HttpResponseCommand.cc
@@ -131,8 +131,7 @@ bool HttpResponseCommand::executeInternal()
getFileEntry()->setLength(totalLength);
getRequestGroup()->initPieceStorage();
getPieceStorage()->markAllPiecesDone();
- // TODO It would be good to issue ChecksumCheckIntegrity here
- // instead of just pretending checksum verification is done.
+ // Just set checksum verification done.
getDownloadContext()->setChecksumVerified(true);
getLogger()->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
util::itos(getRequestGroup()->getGID()).c_str(),
@@ -268,13 +267,15 @@ bool HttpResponseCommand::handleDefaultEncoding
getOption().get()));
if(!infoFile->exists() && getRequestGroup()->downloadFinishedByFileLength()) {
getPieceStorage()->markAllPiecesDone();
- // TODO It would be good to issue ChecksumCheckIntegrity here
- // instead of just pretending checksum verification is done.
- getDownloadContext()->setChecksumVerified(true);
- getLogger()->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
- util::itos(getRequestGroup()->getGID()).c_str(),
- getRequestGroup()->getFirstFilePath().c_str());
- return true;
+ // See also RequestGroup::createInitialCommand()
+ if(!getOption()->getAsBool(PREF_CHECK_INTEGRITY) ||
+ !getDownloadContext()->isChecksumVerificationNeeded()) {
+ getDownloadContext()->setChecksumVerified(true);
+ getLogger()->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
+ util::itos(getRequestGroup()->getGID()).c_str(),
+ getRequestGroup()->getFirstFilePath().c_str());
+ return true;
+ }
}
getRequestGroup()->loadAndOpenFile(infoFile);
File file(getRequestGroup()->getFirstFilePath());
@@ -376,8 +377,7 @@ bool HttpResponseCommand::handleOtherEncoding
if(getRequestGroup()->downloadFinishedByFileLength()) {
getRequestGroup()->initPieceStorage();
getPieceStorage()->markAllPiecesDone();
- // TODO It would be good to issue ChecksumCheckIntegrity here
- // instead of just pretending checksum verification is done.
+ // This is zero-size file, so hash check is no use.
getDownloadContext()->setChecksumVerified(true);
getLogger()->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
util::itos(getRequestGroup()->getGID()).c_str(),