2007-05-20 13:57:56 +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-05-20 13:57:56 +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 "FillRequestGroupCommand.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "DownloadEngine.h"
|
|
|
|
#include "RequestGroupMan.h"
|
|
|
|
#include "RequestGroup.h"
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
#include "RecoverableException.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "message.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Logger.h"
|
2010-11-20 08:21:36 +00:00
|
|
|
#include "LogFactory.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
#include "DownloadContext.h"
|
2010-11-20 08:21:36 +00:00
|
|
|
#include "fmt.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2007-10-11 16:58:24 +00:00
|
|
|
|
2010-03-20 14:30:36 +00:00
|
|
|
FillRequestGroupCommand::FillRequestGroupCommand(cuid_t cuid,
|
2010-04-11 08:28:22 +00:00
|
|
|
DownloadEngine* e):
|
2007-10-11 16:58:24 +00:00
|
|
|
Command(cuid),
|
2010-06-21 13:51:56 +00:00
|
|
|
e_(e)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
|
|
|
setStatusRealtime();
|
|
|
|
}
|
|
|
|
|
|
|
|
FillRequestGroupCommand::~FillRequestGroupCommand() {}
|
2007-05-20 13:57:56 +00:00
|
|
|
|
|
|
|
bool FillRequestGroupCommand::execute()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(e_->isHaltRequested()) {
|
2008-02-11 05:07:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
SharedHandle<RequestGroupMan> rgman = e_->getRequestGroupMan();
|
2010-03-05 14:02:23 +00:00
|
|
|
if(rgman->queueCheckRequested()) {
|
2010-09-08 14:42:03 +00:00
|
|
|
while(rgman->queueCheckRequested()) {
|
|
|
|
try {
|
|
|
|
// During adding RequestGroup,
|
|
|
|
// RequestGroupMan::requestQueueCheck() might be called, so
|
|
|
|
// first clear it here.
|
|
|
|
rgman->clearQueueCheck();
|
|
|
|
rgman->fillRequestGroupFromReserver(e_);
|
|
|
|
} catch(RecoverableException& ex) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
|
2010-09-08 14:42:03 +00:00
|
|
|
// Re-request queue check to fulfill the requests of all
|
|
|
|
// downloads, some might come after this exception.
|
|
|
|
rgman->requestQueueCheck();
|
|
|
|
}
|
2010-03-05 14:02:23 +00:00
|
|
|
}
|
|
|
|
if(rgman->downloadFinished()) {
|
|
|
|
return true;
|
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
e_->addRoutineCommand(this);
|
2007-05-20 13:57:56 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|