2010-06-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Run whole checksum check when download file name and size are
	determined and download is already completed. Related to r2221.
	Guarded ENABLE_MESSAGE_DIGEST where necessary.
	* src/AbstractCommand.cc
	* src/RequestGroup.cc
	* src/message.h
pull/1/head
Tatsuhiro Tsujikawa 2010-06-23 14:45:25 +00:00
parent 66660d10c2
commit 3a3511ee28
4 changed files with 35 additions and 3 deletions

View File

@ -1,3 +1,12 @@
2010-06-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Run whole checksum check when download file name and size are
determined and download is already completed. Related to r2221.
Guarded ENABLE_MESSAGE_DIGEST where necessary.
* src/AbstractCommand.cc
* src/RequestGroup.cc
* src/message.h
2010-06-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made log and log-level option modifiable using

View File

@ -68,6 +68,9 @@
#include "NameResolver.h"
#include "ServerStatMan.h"
#include "FileAllocationEntry.h"
#ifdef ENABLE_MESSAGE_DIGEST
# include "ChecksumCheckIntegrityEntry.h"
#endif // ENABLE_MESSAGE_DIGEST
namespace aria2 {
@ -719,6 +722,23 @@ std::string AbstractCommand::resolveHostname
// function call.
void AbstractCommand::prepareForNextAction(Command* nextCommand)
{
#ifdef ENABLE_MESSAGE_DIGEST
if(requestGroup_->downloadFinished() &&
getDownloadContext()->isChecksumVerificationNeeded()) {
if(getLogger()->info()) {
getLogger()->info(MSG_HASH_CHECK_NOT_DONE);
}
SharedHandle<CheckIntegrityEntry> entry
(new ChecksumCheckIntegrityEntry(requestGroup_));
if(entry->isValidationReady()) {
delete nextCommand;
entry->initValidator();
entry->cutTrailingGarbage();
e_->getCheckIntegrityMan()->pushEntry(entry);
return;
}
}
#endif // ENABLE_MESSAGE_DIGEST
SharedHandle<CheckIntegrityEntry> entry
(new StreamCheckIntegrityEntry(requestGroup_, nextCommand));

View File

@ -395,11 +395,11 @@ void RequestGroup::createInitialCommand
downloadContext_->getBasePath().c_str());
} else {
loadAndOpenFile(infoFile);
#ifdef ENABLE_MESSAGE_DIGEST
if(downloadFinished() &&
downloadContext_->isChecksumVerificationNeeded()) {
if(logger_->info()) {
logger_->info("File has already been downloaded but hash check has"
" not been done yet.");
logger_->info(MSG_HASH_CHECK_NOT_DONE);
}
SharedHandle<CheckIntegrityEntry> entry
(new ChecksumCheckIntegrityEntry(this));
@ -407,9 +407,10 @@ void RequestGroup::createInitialCommand
entry->initValidator();
entry->cutTrailingGarbage();
e->getCheckIntegrityMan()->pushEntry(entry);
return;
}
return;
}
#endif // ENABLE_MESSAGE_DIGEST
SharedHandle<CheckIntegrityEntry> checkIntegrityEntry
(new StreamCheckIntegrityEntry(this));
processCheckIntegrityEntry(commands, checkIntegrityEntry, e);

View File

@ -188,6 +188,8 @@
#define MSG_METADATA_NOT_SAVED _("Saving metadata as %s failed. Maybe file" \
" already exists.")
#define MSG_DIR_TRAVERSAL_DETECTED _("Detected directory traversal directive in %s")
#define MSG_HASH_CHECK_NOT_DONE \
"File has already been downloaded but hash check has not been done yet."
#define EX_TIME_OUT _("Timeout.")
#define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.")