2007-06-05 11:37:25 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-06-05 11:37:25 +00:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#include "CheckIntegrityEntry.h"
|
2007-11-12 11:28:16 +00:00
|
|
|
#include "IteratableValidator.h"
|
2008-08-26 12:39:07 +00:00
|
|
|
#include "RequestGroup.h"
|
|
|
|
#include "PieceStorage.h"
|
|
|
|
#include "DiskAdaptor.h"
|
2009-03-25 05:43:07 +00:00
|
|
|
#include "prefs.h"
|
|
|
|
#include "FileAllocationEntry.h"
|
|
|
|
#include "DownloadEngine.h"
|
|
|
|
#include "Option.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
CheckIntegrityEntry::CheckIntegrityEntry(RequestGroup* requestGroup,
|
2010-01-05 16:01:46 +00:00
|
|
|
Command* nextCommand):
|
2008-04-20 00:50:22 +00:00
|
|
|
RequestGroupEntry(requestGroup, nextCommand)
|
2007-12-05 17:11:22 +00:00
|
|
|
{}
|
2007-10-11 16:58:24 +00:00
|
|
|
|
2007-12-05 17:11:22 +00:00
|
|
|
CheckIntegrityEntry::~CheckIntegrityEntry() {}
|
2007-06-05 11:37:25 +00:00
|
|
|
|
|
|
|
void CheckIntegrityEntry::validateChunk()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
validator_->validateChunk();
|
2007-06-05 11:37:25 +00:00
|
|
|
}
|
|
|
|
|
2012-07-23 12:36:24 +00:00
|
|
|
int64_t CheckIntegrityEntry::getTotalLength()
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!validator_) {
|
2007-10-11 16:58:24 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
return validator_->getTotalLength();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-23 12:36:24 +00:00
|
|
|
int64_t CheckIntegrityEntry::getCurrentLength()
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!validator_) {
|
2007-10-11 16:58:24 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
return validator_->getCurrentOffset();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CheckIntegrityEntry::finished()
|
2007-06-05 11:37:25 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return validator_->finished();
|
2007-06-05 11:37:25 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2008-08-26 12:39:07 +00:00
|
|
|
void CheckIntegrityEntry::cutTrailingGarbage()
|
|
|
|
{
|
2010-06-09 15:04:01 +00:00
|
|
|
getRequestGroup()->getPieceStorage()->getDiskAdaptor()->cutTrailingGarbage();
|
2008-08-26 12:39:07 +00:00
|
|
|
}
|
|
|
|
|
2009-03-25 05:43:07 +00:00
|
|
|
void CheckIntegrityEntry::proceedFileAllocation
|
2010-02-28 12:30:11 +00:00
|
|
|
(std::vector<Command*>& commands,
|
2009-03-25 05:43:07 +00:00
|
|
|
const SharedHandle<FileAllocationEntry>& entry,
|
|
|
|
DownloadEngine* e)
|
|
|
|
{
|
2010-06-09 15:04:01 +00:00
|
|
|
if(getRequestGroup()->needsFileAllocation()) {
|
2010-06-08 14:11:36 +00:00
|
|
|
e->getFileAllocationMan()->pushEntry(entry);
|
2009-03-25 05:43:07 +00:00
|
|
|
} else {
|
|
|
|
entry->prepareForNextAction(commands, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-09 15:04:01 +00:00
|
|
|
void CheckIntegrityEntry::setValidator
|
|
|
|
(const SharedHandle<IteratableValidator>& validator)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
validator_ = validator;
|
2010-06-09 15:04:01 +00:00
|
|
|
}
|
2009-03-25 05:43:07 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|