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 "RequestGroup.h"
|
2008-11-03 06:49:02 +00:00
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <algorithm>
|
|
|
|
|
2007-12-10 14:01:21 +00:00
|
|
|
#include "PostDownloadHandler.h"
|
2007-05-20 13:57:56 +00:00
|
|
|
#include "DownloadEngine.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "DefaultSegmentManFactory.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "SegmentMan.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "NullProgressInfoFile.h"
|
|
|
|
#include "Dependency.h"
|
2007-05-20 13:57:56 +00:00
|
|
|
#include "prefs.h"
|
2009-06-23 15:35:45 +00:00
|
|
|
#include "CreateRequestCommand.h"
|
2007-05-20 13:57:56 +00:00
|
|
|
#include "File.h"
|
|
|
|
#include "message.h"
|
2009-10-22 15:35:33 +00:00
|
|
|
#include "util.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "LogFactory.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Logger.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "DiskAdaptor.h"
|
|
|
|
#include "DiskWriterFactory.h"
|
2007-10-15 14:55:24 +00:00
|
|
|
#include "RecoverableException.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 "StreamCheckIntegrityEntry.h"
|
|
|
|
#include "CheckIntegrityCommand.h"
|
|
|
|
#include "UnknownLengthPieceStorage.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
#include "DownloadContext.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 "DlAbortEx.h"
|
|
|
|
#include "DownloadFailureException.h"
|
2007-11-13 11:46:58 +00:00
|
|
|
#include "RequestGroupMan.h"
|
2007-11-14 10:10:38 +00:00
|
|
|
#include "DefaultBtProgressInfoFile.h"
|
|
|
|
#include "DefaultPieceStorage.h"
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
#include "DownloadHandlerFactory.h"
|
|
|
|
#include "MemoryBufferPreDownloadHandler.h"
|
|
|
|
#include "DownloadHandlerConstants.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Option.h"
|
|
|
|
#include "FileEntry.h"
|
|
|
|
#include "Request.h"
|
|
|
|
#include "FileAllocationIterator.h"
|
2008-04-27 02:22:14 +00:00
|
|
|
#include "StringFormat.h"
|
2008-05-13 14:15:23 +00:00
|
|
|
#include "A2STR.h"
|
2008-08-04 17:06:47 +00:00
|
|
|
#include "URISelector.h"
|
|
|
|
#include "InOrderURISelector.h"
|
2009-01-31 14:34:29 +00:00
|
|
|
#include "PieceSelector.h"
|
2009-06-06 12:33:07 +00:00
|
|
|
#include "a2functional.h"
|
2009-06-23 15:35:45 +00:00
|
|
|
#include "SocketCore.h"
|
2009-11-29 06:43:38 +00:00
|
|
|
#include "SimpleRandomizer.h"
|
2007-07-04 16:04:57 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2007-10-11 16:58:24 +00:00
|
|
|
# include "CheckIntegrityCommand.h"
|
2007-07-04 16:04:57 +00:00
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-06-28 10:37:15 +00:00
|
|
|
# include "bittorrent_helper.h"
|
|
|
|
# include "BtRegistry.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
# include "BtCheckIntegrityEntry.h"
|
|
|
|
# include "DefaultPeerStorage.h"
|
|
|
|
# include "DefaultBtAnnounce.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
# include "BtRuntime.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
# include "BtSetup.h"
|
|
|
|
# include "BtFileAllocationEntry.h"
|
|
|
|
# include "BtPostDownloadHandler.h"
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
# include "DHTSetup.h"
|
|
|
|
# include "DHTRegistry.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
# include "BtMessageFactory.h"
|
|
|
|
# include "BtRequestFactory.h"
|
|
|
|
# include "BtMessageDispatcher.h"
|
|
|
|
# include "BtMessageReceiver.h"
|
|
|
|
# include "PeerConnection.h"
|
|
|
|
# include "ExtensionMessageFactory.h"
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
# include "DHTPeerAnnounceStorage.h"
|
2008-02-13 15:17:08 +00:00
|
|
|
# include "DHTEntryPointNameResolveCommand.h"
|
2009-01-31 14:34:29 +00:00
|
|
|
# include "LongestSequencePieceSelector.h"
|
2009-11-29 06:43:38 +00:00
|
|
|
# include "PriorityPieceSelector.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
|
|
|
# include "MetalinkPostDownloadHandler.h"
|
|
|
|
#endif // ENABLE_METALINK
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2007-05-20 13:57:56 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
int32_t RequestGroup::_gidCounter = 0;
|
|
|
|
|
2008-05-05 08:25:41 +00:00
|
|
|
const std::string RequestGroup::ACCEPT_METALINK = "application/metalink+xml";
|
2008-04-25 17:44:03 +00:00
|
|
|
|
2009-06-29 08:42:58 +00:00
|
|
|
RequestGroup::RequestGroup(const SharedHandle<Option>& option):
|
2010-01-10 07:51:45 +00:00
|
|
|
_gid(newGID()),
|
2009-05-08 16:41:21 +00:00
|
|
|
_option(new Option(*option.get())),
|
2008-11-13 13:40:40 +00:00
|
|
|
_numConcurrentCommand(option->getAsInt(PREF_SPLIT)),
|
2007-10-11 16:58:24 +00:00
|
|
|
_numStreamConnection(0),
|
|
|
|
_numCommand(0),
|
2009-05-08 16:41:21 +00:00
|
|
|
_segmentManFactory(new DefaultSegmentManFactory(_option.get())),
|
2009-10-05 13:35:09 +00:00
|
|
|
_saveControlFile(true),
|
2007-10-11 16:58:24 +00:00
|
|
|
_progressInfoFile(new NullProgressInfoFile()),
|
|
|
|
_preLocalFileCheckEnabled(true),
|
|
|
|
_haltRequested(false),
|
2007-12-07 13:33:59 +00:00
|
|
|
_forceHaltRequested(false),
|
2009-05-09 04:11:31 +00:00
|
|
|
_haltReason(RequestGroup::NONE),
|
2008-08-04 17:06:47 +00:00
|
|
|
_uriSelector(new InOrderURISelector()),
|
2008-11-05 10:30:43 +00:00
|
|
|
_lastModifiedTime(Time::null()),
|
2008-09-10 14:56:44 +00:00
|
|
|
_fileNotFoundCount(0),
|
2009-02-01 02:55:44 +00:00
|
|
|
_timeout(option->getAsInt(PREF_TIMEOUT)),
|
2008-11-14 12:02:16 +00:00
|
|
|
_inMemoryDownload(false),
|
2009-02-28 11:48:26 +00:00
|
|
|
_maxDownloadSpeedLimit(option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)),
|
|
|
|
_maxUploadSpeedLimit(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)),
|
2009-12-20 09:49:43 +00:00
|
|
|
_belongsToGID(0),
|
2007-10-11 16:58:24 +00:00
|
|
|
_logger(LogFactory::getInstance())
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2009-03-25 05:43:07 +00:00
|
|
|
_fileAllocationEnabled = _option->get(PREF_FILE_ALLOCATION) != V_NONE;
|
2008-05-05 08:25:41 +00:00
|
|
|
// Add types to be sent as a Accept header value here.
|
2008-04-25 17:44:03 +00:00
|
|
|
// It would be good to put this value in Option so that user can tweak
|
|
|
|
// and add this list.
|
2008-05-05 08:25:41 +00:00
|
|
|
// ACCEPT_METALINK is used for `transparent metalink'.
|
|
|
|
addAcceptType(ACCEPT_METALINK);
|
2009-03-08 10:20:42 +00:00
|
|
|
if(!_option->getAsBool(PREF_DRY_RUN)) {
|
|
|
|
initializePreDownloadHandler();
|
|
|
|
initializePostDownloadHandler();
|
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
RequestGroup::~RequestGroup() {}
|
|
|
|
|
2009-05-29 12:12:22 +00:00
|
|
|
const SegmentManHandle& RequestGroup::initSegmentMan()
|
2007-06-03 14:24:37 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
_segmentMan = _segmentManFactory->createNewInstance(_downloadContext,
|
2010-01-05 16:01:46 +00:00
|
|
|
_pieceStorage);
|
2007-10-11 16:58:24 +00:00
|
|
|
return _segmentMan;
|
2007-06-03 14:24:37 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
bool RequestGroup::downloadFinished() const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_pieceStorage.isNull()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return _pieceStorage->downloadFinished();
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-29 14:06:59 +00:00
|
|
|
bool RequestGroup::allDownloadFinished() const
|
|
|
|
{
|
|
|
|
if(_pieceStorage.isNull()) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return _pieceStorage->allDownloadFinished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-29 08:42:58 +00:00
|
|
|
downloadresultcode::RESULT RequestGroup::downloadResult() const
|
2009-01-12 12:27:34 +00:00
|
|
|
{
|
|
|
|
if (downloadFinished())
|
2009-06-29 08:42:58 +00:00
|
|
|
return downloadresultcode::FINISHED;
|
2009-01-12 12:27:34 +00:00
|
|
|
else {
|
2009-06-29 08:42:58 +00:00
|
|
|
if (_lastUriResult.isNull()) {
|
2009-05-09 04:11:31 +00:00
|
|
|
if(_haltReason == RequestGroup::USER_REQUEST) {
|
2010-01-05 16:01:46 +00:00
|
|
|
return downloadresultcode::IN_PROGRESS;
|
2009-05-09 04:11:31 +00:00
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
return downloadresultcode::UNKNOWN_ERROR;
|
2009-05-09 04:11:31 +00:00
|
|
|
}
|
2009-01-12 12:27:34 +00:00
|
|
|
} else {
|
2009-06-29 08:42:58 +00:00
|
|
|
return _lastUriResult->getResult();
|
2009-01-12 12:27:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
void RequestGroup::closeFile()
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
if(!_pieceStorage.isNull()) {
|
|
|
|
_pieceStorage->getDiskAdaptor()->closeFile();
|
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 13:17:48 +00:00
|
|
|
void RequestGroup::createInitialCommand
|
|
|
|
(std::deque<Command*>& commands, DownloadEngine* e)
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
{
|
2009-06-28 10:37:15 +00:00
|
|
|
if(_downloadContext->hasAttribute(bittorrent::BITTORRENT)) {
|
|
|
|
const BDE& torrentAttrs =
|
2010-01-05 16:01:46 +00:00
|
|
|
_downloadContext->getAttribute(bittorrent::BITTORRENT);
|
2009-11-23 13:17:48 +00:00
|
|
|
bool metadataGetMode = !torrentAttrs.containsKey(bittorrent::METADATA);
|
2009-03-08 10:20:42 +00:00
|
|
|
if(_option->getAsBool(PREF_DRY_RUN)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
|
|
|
("Cancel BitTorrent download in dry-run context.");
|
2009-03-08 10:20:42 +00:00
|
|
|
}
|
2009-03-08 12:47:33 +00:00
|
|
|
SharedHandle<BtRegistry> btRegistry = e->getBtRegistry();
|
2009-06-28 10:37:15 +00:00
|
|
|
if(!btRegistry->getDownloadContext
|
2010-01-05 16:01:46 +00:00
|
|
|
(torrentAttrs[bittorrent::INFO_HASH].s()).isNull()) {
|
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
|
|
|
(StringFormat
|
|
|
|
("InfoHash %s is already registered.",
|
|
|
|
bittorrent::getInfoHashString(_downloadContext).c_str()).str());
|
2009-03-08 12:47:33 +00:00
|
|
|
}
|
2009-11-23 13:17:48 +00:00
|
|
|
if(metadataGetMode) {
|
2010-01-05 16:01:46 +00:00
|
|
|
// Use UnknownLengthPieceStorage.
|
|
|
|
initPieceStorage();
|
2009-11-23 13:17:48 +00:00
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
|
|
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
|
|
|
_downloadContext->getBasePath().c_str()).str());
|
|
|
|
}
|
|
|
|
initPieceStorage();
|
|
|
|
if(_downloadContext->getFileEntries().size() > 1) {
|
|
|
|
_pieceStorage->setupFileFilter();
|
|
|
|
}
|
2007-11-21 16:14:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 13:17:48 +00:00
|
|
|
SharedHandle<DefaultBtProgressInfoFile> progressInfoFile;
|
|
|
|
if(!metadataGetMode) {
|
2010-01-05 16:01:46 +00:00
|
|
|
progressInfoFile.reset(new DefaultBtProgressInfoFile(_downloadContext,
|
|
|
|
_pieceStorage,
|
|
|
|
_option.get()));
|
2009-11-23 13:17:48 +00:00
|
|
|
}
|
2009-06-17 11:51:44 +00:00
|
|
|
|
2008-04-20 00:50:22 +00:00
|
|
|
BtRuntimeHandle btRuntime(new BtRuntime());
|
2009-01-18 10:11:08 +00:00
|
|
|
btRuntime->setMaxPeers(_option->getAsInt(PREF_BT_MAX_PEERS));
|
2008-11-03 06:49:02 +00:00
|
|
|
_btRuntime = btRuntime;
|
2009-11-23 13:17:48 +00:00
|
|
|
if(!progressInfoFile.isNull()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
progressInfoFile->setBtRuntime(btRuntime);
|
2009-11-23 13:17:48 +00:00
|
|
|
}
|
2008-11-03 06:49:02 +00:00
|
|
|
|
|
|
|
SharedHandle<DefaultPeerStorage> peerStorage
|
2010-01-05 16:01:46 +00:00
|
|
|
(new DefaultPeerStorage(_option.get()));
|
2008-11-03 06:49:02 +00:00
|
|
|
peerStorage->setBtRuntime(btRuntime);
|
|
|
|
peerStorage->setPieceStorage(_pieceStorage);
|
|
|
|
_peerStorage = peerStorage;
|
2009-11-23 13:17:48 +00:00
|
|
|
if(!progressInfoFile.isNull()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
progressInfoFile->setPeerStorage(peerStorage);
|
2009-11-23 13:17:48 +00:00
|
|
|
}
|
2008-11-03 06:49:02 +00:00
|
|
|
|
|
|
|
SharedHandle<DefaultBtAnnounce> btAnnounce
|
2010-01-05 16:01:46 +00:00
|
|
|
(new DefaultBtAnnounce(_downloadContext, _option.get()));
|
2008-11-03 06:49:02 +00:00
|
|
|
btAnnounce->setBtRuntime(btRuntime);
|
|
|
|
btAnnounce->setPieceStorage(_pieceStorage);
|
|
|
|
btAnnounce->setPeerStorage(peerStorage);
|
2009-03-20 13:44:03 +00:00
|
|
|
btAnnounce->setUserDefinedInterval
|
2010-01-05 16:01:46 +00:00
|
|
|
(_option->getAsInt(PREF_BT_TRACKER_INTERVAL));
|
2007-10-11 16:58:24 +00:00
|
|
|
btAnnounce->shuffleAnnounce();
|
|
|
|
|
2010-01-10 07:51:45 +00:00
|
|
|
assert(btRegistry->get(_gid).isNull());
|
2009-11-25 15:49:20 +00:00
|
|
|
btRegistry->put(_gid,
|
2010-01-05 16:01:46 +00:00
|
|
|
BtObject(_downloadContext,
|
|
|
|
_pieceStorage,
|
|
|
|
peerStorage,
|
|
|
|
btAnnounce,
|
|
|
|
btRuntime,
|
|
|
|
(progressInfoFile.isNull()?
|
|
|
|
_progressInfoFile:
|
|
|
|
SharedHandle<BtProgressInfoFile>
|
|
|
|
(progressInfoFile))));
|
2009-11-23 13:17:48 +00:00
|
|
|
if(metadataGetMode) {
|
2010-01-05 16:01:46 +00:00
|
|
|
if(_option->getAsBool(PREF_ENABLE_DHT)) {
|
|
|
|
std::deque<Command*> dhtCommands;
|
|
|
|
DHTSetup().setup(dhtCommands, e, _option.get());
|
|
|
|
e->addCommand(dhtCommands);
|
|
|
|
} else {
|
|
|
|
_logger->notice("For BitTorrent Magnet URI, enabling DHT is strongly"
|
|
|
|
" recommended. See --enable-dht option.");
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedHandle<CheckIntegrityEntry> entry
|
|
|
|
(new BtCheckIntegrityEntry(this));
|
|
|
|
entry->onDownloadIncomplete(commands, e);
|
|
|
|
|
|
|
|
return;
|
2009-11-23 13:17:48 +00:00
|
|
|
}
|
2009-06-17 11:51:44 +00:00
|
|
|
|
2007-12-26 15:11:42 +00:00
|
|
|
// Remove the control file if download file doesn't exist
|
|
|
|
if(progressInfoFile->exists() && !_pieceStorage->getDiskAdaptor()->fileExists()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
progressInfoFile->removeFile();
|
|
|
|
_logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
|
|
|
|
progressInfoFile->getFilename().c_str(),
|
|
|
|
_downloadContext->getBasePath().c_str());
|
2007-12-26 15:11:42 +00:00
|
|
|
}
|
2009-05-04 07:50:38 +00:00
|
|
|
{
|
2010-01-05 16:01:46 +00:00
|
|
|
uint64_t actualFileSize = _pieceStorage->getDiskAdaptor()->size();
|
|
|
|
if(actualFileSize == _downloadContext->getTotalLength()) {
|
|
|
|
// First, make DiskAdaptor read-only mode to allow the
|
|
|
|
// program to seed file in read-only media.
|
|
|
|
_pieceStorage->getDiskAdaptor()->enableReadOnly();
|
|
|
|
} else {
|
|
|
|
// Open file in writable mode to allow the program
|
|
|
|
// truncate the file to _downloadContext->getTotalLength()
|
|
|
|
_logger->debug("File size not match. File is opened in writable mode."
|
|
|
|
" Expected:%s Actual:%s",
|
|
|
|
util::uitos(_downloadContext->getTotalLength()).c_str(),
|
|
|
|
util::uitos(actualFileSize).c_str());
|
|
|
|
}
|
2009-05-04 07:50:38 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
// Call Load, Save and file allocation command here
|
|
|
|
if(progressInfoFile->exists()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
// load .aria2 file if it exists.
|
|
|
|
progressInfoFile->load();
|
|
|
|
_pieceStorage->getDiskAdaptor()->openFile();
|
2007-08-28 15:46:49 +00:00
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
if(_pieceStorage->getDiskAdaptor()->fileExists()) {
|
|
|
|
if(!_option->getAsBool(PREF_CHECK_INTEGRITY) &&
|
|
|
|
!_option->getAsBool(PREF_ALLOW_OVERWRITE) &&
|
|
|
|
!_option->getAsBool(PREF_BT_SEED_UNVERIFIED)) {
|
|
|
|
// TODO we need this->haltRequested = true?
|
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
|
|
|
(StringFormat
|
|
|
|
(MSG_FILE_ALREADY_EXISTS,
|
|
|
|
_downloadContext->getBasePath().c_str()).str());
|
|
|
|
} else {
|
|
|
|
_pieceStorage->getDiskAdaptor()->openFile();
|
|
|
|
}
|
|
|
|
if(_option->getAsBool(PREF_BT_SEED_UNVERIFIED)) {
|
|
|
|
_pieceStorage->markAllPiecesDone();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_pieceStorage->getDiskAdaptor()->openFile();
|
|
|
|
}
|
2007-08-28 15:46:49 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
_progressInfoFile = progressInfoFile;
|
2009-05-04 07:50:38 +00:00
|
|
|
|
2009-06-28 10:37:15 +00:00
|
|
|
if(torrentAttrs[bittorrent::PRIVATE].i() == 0 &&
|
2010-01-05 16:01:46 +00:00
|
|
|
_option->getAsBool(PREF_ENABLE_DHT)) {
|
2010-01-11 15:35:12 +00:00
|
|
|
std::deque<Command*> dhtCommands;
|
|
|
|
DHTSetup().setup(dhtCommands, e, _option.get());
|
|
|
|
e->addCommand(dhtCommands);
|
2010-01-05 16:01:46 +00:00
|
|
|
if(!torrentAttrs[bittorrent::NODES].empty() && DHTSetup::initialized()) {
|
|
|
|
std::deque<std::pair<std::string, uint16_t> > entryPoints;
|
|
|
|
const BDE& nodes = torrentAttrs[bittorrent::NODES];
|
|
|
|
for(BDE::List::const_iterator i = nodes.listBegin();
|
|
|
|
i != nodes.listEnd(); ++i) {
|
|
|
|
std::pair<std::string, uint16_t> addr
|
|
|
|
((*i)[bittorrent::HOSTNAME].s(), (*i)[bittorrent::PORT].i());
|
|
|
|
entryPoints.push_back(addr);
|
|
|
|
}
|
|
|
|
DHTEntryPointNameResolveCommand* command =
|
|
|
|
new DHTEntryPointNameResolveCommand(e->newCUID(), e, entryPoints);
|
|
|
|
command->setTaskQueue(DHTRegistry::_taskQueue);
|
|
|
|
command->setTaskFactory(DHTRegistry::_taskFactory);
|
|
|
|
command->setRoutingTable(DHTRegistry::_routingTable);
|
|
|
|
command->setLocalNode(DHTRegistry::_localNode);
|
|
|
|
e->commands.push_back(command);
|
|
|
|
}
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
}
|
2008-04-20 00:50:22 +00:00
|
|
|
CheckIntegrityEntryHandle entry(new BtCheckIntegrityEntry(this));
|
2008-07-12 13:54:36 +00:00
|
|
|
// --bt-seed-unverified=true is given and download has completed, skip
|
|
|
|
// validation for piece hashes.
|
|
|
|
if(_option->getAsBool(PREF_BT_SEED_UNVERIFIED) &&
|
2010-01-05 16:01:46 +00:00
|
|
|
_pieceStorage->downloadFinished()) {
|
|
|
|
entry->onDownloadFinished(commands, e);
|
2008-07-08 14:18:51 +00:00
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
processCheckIntegrityEntry(commands, entry, e);
|
2008-07-08 14:18:51 +00:00
|
|
|
}
|
2008-05-11 09:36:39 +00:00
|
|
|
return;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-07-11 15:50:21 +00:00
|
|
|
// TODO Currently, BitTorrent+WEB-Seeding is only way to download
|
|
|
|
// multiple files in one RequestGroup. In this context, we don't
|
|
|
|
// have BitTorrent, so add assertion here. This situation will be
|
|
|
|
// changed if Metalink spec is formalized to support multi-file
|
|
|
|
// torrent.
|
|
|
|
assert(_downloadContext->getFileEntries().size() == 1);
|
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
|
|
|
// TODO I assume here when totallength is set to DownloadContext and it is
|
|
|
|
// not 0, then filepath is also set DownloadContext correctly....
|
2009-03-08 10:20:42 +00:00
|
|
|
if(_option->getAsBool(PREF_DRY_RUN) ||
|
|
|
|
_downloadContext->getTotalLength() == 0) {
|
2009-07-04 14:32:53 +00:00
|
|
|
createNextCommand(commands, e, 1);
|
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
|
|
|
}else {
|
2007-11-13 11:46:58 +00:00
|
|
|
if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
2010-01-05 16:01:46 +00:00
|
|
|
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
|
|
|
|
_downloadContext->getBasePath().c_str()).str());
|
2007-11-13 11:46:58 +00:00
|
|
|
}
|
2009-05-07 03:49:27 +00:00
|
|
|
adjustFilename
|
|
|
|
(SharedHandle<BtProgressInfoFile>(new DefaultBtProgressInfoFile
|
2010-01-05 16:01:46 +00:00
|
|
|
(_downloadContext,
|
|
|
|
SharedHandle<PieceStorage>(),
|
|
|
|
_option.get())));
|
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
|
|
|
initPieceStorage();
|
2008-05-11 09:36:39 +00:00
|
|
|
BtProgressInfoFileHandle infoFile
|
2009-05-08 16:41:21 +00:00
|
|
|
(new DefaultBtProgressInfoFile(_downloadContext, _pieceStorage,
|
2010-01-05 16:01:46 +00:00
|
|
|
_option.get()));
|
2009-05-07 03:49:27 +00:00
|
|
|
if(!infoFile->exists() && downloadFinishedByFileLength()) {
|
|
|
|
_pieceStorage->markAllPiecesDone();
|
|
|
|
_logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
2010-01-05 16:01:46 +00:00
|
|
|
_gid, _downloadContext->getBasePath().c_str());
|
2009-05-07 03:49:27 +00:00
|
|
|
} else {
|
2008-05-11 09:36:39 +00:00
|
|
|
loadAndOpenFile(infoFile);
|
|
|
|
SharedHandle<CheckIntegrityEntry> checkIntegrityEntry
|
2010-01-05 16:01:46 +00:00
|
|
|
(new StreamCheckIntegrityEntry(this));
|
2008-05-11 09:36:39 +00:00
|
|
|
processCheckIntegrityEntry(commands, checkIntegrityEntry, e);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 09:36:39 +00:00
|
|
|
void RequestGroup::processCheckIntegrityEntry(std::deque<Command*>& commands,
|
2010-01-05 16:01:46 +00:00
|
|
|
const CheckIntegrityEntryHandle& entry,
|
|
|
|
DownloadEngine* e)
|
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
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2009-05-08 16:41:21 +00:00
|
|
|
if(_option->getAsBool(PREF_CHECK_INTEGRITY) &&
|
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
|
|
|
entry->isValidationReady()) {
|
|
|
|
entry->initValidator();
|
2009-05-03 11:00:39 +00:00
|
|
|
entry->cutTrailingGarbage();
|
2009-10-05 13:35:09 +00:00
|
|
|
// Don't save control file(.aria2 file) when user presses
|
|
|
|
// control-c key while aria2 is checking hashes. If control file
|
|
|
|
// doesn't exist when aria2 launched, the completed length in
|
|
|
|
// saved control file will be 0 byte and this confuses user.
|
|
|
|
// enableSaveControlFile() will be called after hash checking is
|
|
|
|
// done. See CheckIntegrityCommand.
|
|
|
|
disableSaveControlFile();
|
2009-01-24 10:40:42 +00:00
|
|
|
e->_checkIntegrityMan->pushEntry(entry);
|
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
|
|
|
} else
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
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
|
|
|
{
|
2008-05-11 09:36:39 +00:00
|
|
|
entry->onDownloadIncomplete(commands, e);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::initPieceStorage()
|
|
|
|
{
|
2008-11-26 15:22:54 +00:00
|
|
|
if(_downloadContext->knowsTotalLength()) {
|
2009-01-31 14:34:29 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-05-06 07:49:22 +00:00
|
|
|
SharedHandle<DefaultPieceStorage> ps
|
2009-05-08 16:41:21 +00:00
|
|
|
(new DefaultPieceStorage(_downloadContext, _option.get()));
|
2009-11-29 06:43:38 +00:00
|
|
|
if(_downloadContext->hasAttribute(bittorrent::BITTORRENT)) {
|
|
|
|
if(isUriSuppliedForRequsetFileEntry
|
2010-01-05 16:01:46 +00:00
|
|
|
(_downloadContext->getFileEntries().begin(),
|
|
|
|
_downloadContext->getFileEntries().end())) {
|
|
|
|
// Use LongestSequencePieceSelector when HTTP/FTP/BitTorrent
|
|
|
|
// integrated downloads. Currently multi-file integrated
|
|
|
|
// download is not supported.
|
|
|
|
_logger->debug("Using LongestSequencePieceSelector");
|
|
|
|
ps->setPieceSelector
|
|
|
|
(SharedHandle<PieceSelector>(new LongestSequencePieceSelector()));
|
2009-11-29 06:43:38 +00:00
|
|
|
}
|
|
|
|
if(_option->defined(PREF_BT_PRIORITIZE_PIECE)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
std::vector<size_t> result;
|
|
|
|
util::parsePrioritizePieceRange
|
|
|
|
(result, _option->get(PREF_BT_PRIORITIZE_PIECE),
|
|
|
|
_downloadContext->getFileEntries(),
|
|
|
|
_downloadContext->getPieceLength());
|
|
|
|
if(!result.empty()) {
|
|
|
|
std::random_shuffle(result.begin(), result.end(),
|
|
|
|
*(SimpleRandomizer::getInstance().get()));
|
|
|
|
SharedHandle<PriorityPieceSelector> priSelector
|
|
|
|
(new PriorityPieceSelector(ps->getPieceSelector()));
|
|
|
|
priSelector->setPriorityPiece(result.begin(), result.end());
|
|
|
|
ps->setPieceSelector(priSelector);
|
|
|
|
}
|
2009-11-29 06:43:38 +00:00
|
|
|
}
|
2009-01-31 14:34:29 +00:00
|
|
|
}
|
|
|
|
#else // !ENABLE_BITTORRENT
|
|
|
|
SharedHandle<DefaultPieceStorage> ps
|
2009-05-08 16:41:21 +00:00
|
|
|
(new DefaultPieceStorage(_downloadContext, _option.get()));
|
2009-01-31 14:34:29 +00:00
|
|
|
#endif // !ENABLE_BITTORRENT
|
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
|
|
|
if(!_diskWriterFactory.isNull()) {
|
|
|
|
ps->setDiskWriterFactory(_diskWriterFactory);
|
|
|
|
}
|
|
|
|
_pieceStorage = ps;
|
|
|
|
} else {
|
2008-11-26 15:22:54 +00:00
|
|
|
UnknownLengthPieceStorageHandle ps
|
2009-05-08 16:41:21 +00:00
|
|
|
(new UnknownLengthPieceStorage(_downloadContext, _option.get()));
|
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
|
|
|
if(!_diskWriterFactory.isNull()) {
|
|
|
|
ps->setDiskWriterFactory(_diskWriterFactory);
|
|
|
|
}
|
|
|
|
_pieceStorage = ps;
|
|
|
|
}
|
|
|
|
_pieceStorage->initStorage();
|
|
|
|
initSegmentMan();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RequestGroup::downloadFinishedByFileLength()
|
|
|
|
{
|
2007-11-23 11:15:19 +00:00
|
|
|
// assuming that a control file doesn't exist.
|
2007-11-25 11:48:44 +00:00
|
|
|
if(!isPreLocalFileCheckEnabled() ||
|
2008-05-18 10:25:41 +00:00
|
|
|
_option->getAsBool(PREF_ALLOW_OVERWRITE) ||
|
|
|
|
(_option->getAsBool(PREF_CHECK_INTEGRITY) &&
|
2008-03-15 04:19:46 +00:00
|
|
|
!_downloadContext->getPieceHashes().empty())) {
|
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
|
|
|
return false;
|
|
|
|
}
|
2009-05-07 03:49:27 +00:00
|
|
|
if(!_downloadContext->knowsTotalLength()) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-28 10:37:15 +00:00
|
|
|
File outfile(getFirstFilePath());
|
2009-05-07 03:49:27 +00:00
|
|
|
if(outfile.exists() && _downloadContext->getTotalLength() == outfile.size()) {
|
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
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-07 03:49:27 +00:00
|
|
|
void RequestGroup::adjustFilename
|
|
|
|
(const SharedHandle<BtProgressInfoFile>& infoFile)
|
|
|
|
{
|
|
|
|
if(!isPreLocalFileCheckEnabled()) {
|
|
|
|
// OK, no need to care about filename.
|
|
|
|
} else if(infoFile->exists()) {
|
|
|
|
// Use current filename
|
|
|
|
} else if(downloadFinishedByFileLength()) {
|
|
|
|
// File was downloaded already, no need to change file name.
|
|
|
|
} else {
|
2009-06-28 10:37:15 +00:00
|
|
|
File outfile(getFirstFilePath());
|
2009-05-07 03:49:27 +00:00
|
|
|
if(outfile.exists() && _option->getAsBool(PREF_CONTINUE) &&
|
|
|
|
outfile.size() <= _downloadContext->getTotalLength()) {
|
|
|
|
// File exists but user decided to resume it.
|
|
|
|
} else {
|
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
|
|
|
if(outfile.exists() && _option->getAsBool(PREF_CHECK_INTEGRITY)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
// check-integrity existing file
|
2009-05-07 03:49:27 +00:00
|
|
|
} else {
|
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
2010-01-05 16:01:46 +00:00
|
|
|
shouldCancelDownloadForSafety();
|
2009-05-07 03:49:27 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
|
|
|
}
|
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoFile)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
if(!isPreLocalFileCheckEnabled()) {
|
|
|
|
_pieceStorage->getDiskAdaptor()->initAndOpenFile();
|
|
|
|
return;
|
|
|
|
}
|
2007-12-26 15:11:42 +00:00
|
|
|
// Remove the control file if download file doesn't exist
|
|
|
|
if(progressInfoFile->exists() && !_pieceStorage->getDiskAdaptor()->fileExists()) {
|
|
|
|
progressInfoFile->removeFile();
|
|
|
|
_logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
|
2010-01-05 16:01:46 +00:00
|
|
|
progressInfoFile->getFilename().c_str(),
|
|
|
|
_downloadContext->getBasePath().c_str());
|
2007-12-26 15:11:42 +00:00
|
|
|
}
|
2009-05-07 03:49:27 +00:00
|
|
|
|
|
|
|
if(progressInfoFile->exists()) {
|
|
|
|
progressInfoFile->load();
|
|
|
|
_pieceStorage->getDiskAdaptor()->openExistingFile();
|
|
|
|
} else {
|
2009-06-28 10:37:15 +00:00
|
|
|
File outfile(getFirstFilePath());
|
2009-05-07 03:49:27 +00:00
|
|
|
if(outfile.exists() && _option->getAsBool(PREF_CONTINUE) &&
|
2010-01-05 16:01:46 +00:00
|
|
|
outfile.size() <= getTotalLength()) {
|
|
|
|
_pieceStorage->getDiskAdaptor()->openExistingFile();
|
|
|
|
_pieceStorage->markPiecesDone(outfile.size());
|
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
|
|
|
} else {
|
2009-05-07 03:49:27 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2010-01-05 16:01:46 +00:00
|
|
|
if(outfile.exists() && _option->getAsBool(PREF_CHECK_INTEGRITY)) {
|
|
|
|
_pieceStorage->getDiskAdaptor()->openExistingFile();
|
|
|
|
} else {
|
2008-05-05 10:10:15 +00:00
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
2010-01-05 16:01:46 +00:00
|
|
|
_pieceStorage->getDiskAdaptor()->initAndOpenFile();
|
2008-05-05 10:10:15 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
2009-05-07 03:49:27 +00:00
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
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
|
|
|
}
|
2007-08-28 15:46:49 +00:00
|
|
|
}
|
2009-05-07 03:49:27 +00:00
|
|
|
setProgressInfoFile(progressInfoFile);
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(RecoverableException& e) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2008-04-27 02:22:14 +00:00
|
|
|
(StringFormat(EX_DOWNLOAD_ABORTED).str(), e);
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2007-11-23 11:15:19 +00:00
|
|
|
// assuming that a control file does not exist
|
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
|
|
|
void RequestGroup::shouldCancelDownloadForSafety()
|
|
|
|
{
|
2008-05-18 10:25:41 +00:00
|
|
|
if(_option->getAsBool(PREF_ALLOW_OVERWRITE)) {
|
2007-11-23 11:15:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-06-28 10:37:15 +00:00
|
|
|
File outfile(getFirstFilePath());
|
2007-11-23 11:15:19 +00:00
|
|
|
if(outfile.exists()) {
|
2008-05-18 10:25:41 +00:00
|
|
|
if(_option->getAsBool(PREF_AUTO_FILE_RENAMING)) {
|
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
|
|
|
if(tryAutoFileRenaming()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
_logger->notice(MSG_FILE_RENAMED, getFirstFilePath().c_str());
|
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
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
|
|
|
(StringFormat("File renaming failed: %s",
|
|
|
|
getFirstFilePath().c_str()).str());
|
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
|
|
|
}
|
2007-11-23 11:15:19 +00:00
|
|
|
} else {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
2010-01-05 16:01:46 +00:00
|
|
|
(StringFormat(MSG_FILE_ALREADY_EXISTS,
|
|
|
|
getFirstFilePath().c_str()).str());
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RequestGroup::tryAutoFileRenaming()
|
|
|
|
{
|
2009-06-28 10:37:15 +00:00
|
|
|
std::string filepath = getFirstFilePath();
|
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
|
|
|
if(filepath.empty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2008-03-09 12:24:01 +00:00
|
|
|
for(unsigned int i = 1; i < 10000; ++i) {
|
2010-01-28 14:33:23 +00:00
|
|
|
File newfile(strconcat(filepath, A2STR::DOT_C, util::uitos(i)));
|
2009-07-11 10:19:10 +00:00
|
|
|
File ctrlfile(newfile.getPath()+DefaultBtProgressInfoFile::getSuffix());
|
2009-06-28 10:37:15 +00:00
|
|
|
if(!newfile.exists() || (newfile.exists() && ctrlfile.exists())) {
|
|
|
|
_downloadContext->getFirstFileEntry()->setPath(newfile.getPath());
|
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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 09:36:39 +00:00
|
|
|
void RequestGroup::createNextCommandWithAdj(std::deque<Command*>& commands,
|
2010-01-05 16:01:46 +00:00
|
|
|
DownloadEngine* e, int numAdj)
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2008-08-07 15:24:13 +00:00
|
|
|
int numCommand;
|
|
|
|
if(getTotalLength() == 0) {
|
|
|
|
numCommand = 1+numAdj;
|
2008-03-09 12:24:01 +00:00
|
|
|
} else {
|
2009-06-29 08:42:58 +00:00
|
|
|
numCommand = std::min(_downloadContext->getNumPieces(),
|
2010-01-05 16:01:46 +00:00
|
|
|
_numConcurrentCommand);
|
2008-08-27 15:02:21 +00:00
|
|
|
numCommand += numAdj;
|
2008-08-07 15:24:13 +00:00
|
|
|
}
|
|
|
|
if(numCommand > 0) {
|
|
|
|
createNextCommand(commands, e, numCommand);
|
2008-03-09 12:24:01 +00:00
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2008-05-11 09:36:39 +00:00
|
|
|
void RequestGroup::createNextCommand(std::deque<Command*>& commands,
|
2010-01-05 16:01:46 +00:00
|
|
|
DownloadEngine* e,
|
|
|
|
unsigned int numCommand)
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2009-06-23 15:35:45 +00:00
|
|
|
for(; numCommand--; ) {
|
|
|
|
Command* command = new CreateRequestCommand(e->newCUID(), this, e);
|
|
|
|
commands.push_back(command);
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
2009-06-20 02:33:42 +00:00
|
|
|
if(!commands.empty()) {
|
|
|
|
e->setNoWait(true);
|
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2009-06-28 10:37:15 +00:00
|
|
|
std::string RequestGroup::getFirstFilePath() const
|
2007-07-01 10:40:30 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
assert(!_downloadContext.isNull());
|
2008-11-14 12:32:54 +00:00
|
|
|
if(inMemoryDownload()) {
|
|
|
|
static const std::string DIR_MEMORY("[MEMORY]");
|
2009-06-28 10:37:15 +00:00
|
|
|
return DIR_MEMORY+File(_downloadContext->getFirstFileEntry()->getPath()).getBasename();
|
2007-07-01 10:40:30 +00:00
|
|
|
} else {
|
2009-06-28 10:37:15 +00:00
|
|
|
return _downloadContext->getFirstFileEntry()->getPath();
|
2007-07-01 10:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
uint64_t RequestGroup::getTotalLength() const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_pieceStorage.isNull()) {
|
|
|
|
return 0;
|
2007-05-20 13:57:56 +00:00
|
|
|
} else {
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_pieceStorage->isSelectiveDownloadingMode()) {
|
|
|
|
return _pieceStorage->getFilteredTotalLength();
|
2007-05-20 13:57:56 +00:00
|
|
|
} else {
|
2007-10-11 16:58:24 +00:00
|
|
|
return _pieceStorage->getTotalLength();
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
uint64_t RequestGroup::getCompletedLength() const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_pieceStorage.isNull()) {
|
|
|
|
return 0;
|
2007-05-20 13:57:56 +00:00
|
|
|
} else {
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_pieceStorage->isSelectiveDownloadingMode()) {
|
|
|
|
return _pieceStorage->getFilteredCompletedLength();
|
2007-05-31 15:56:20 +00:00
|
|
|
} else {
|
2007-10-11 16:58:24 +00:00
|
|
|
return _pieceStorage->getCompletedLength();
|
2007-05-31 15:56:20 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void RequestGroup::validateFilename(const std::string& expectedFilename,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& actualFilename) const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
|
|
|
if(expectedFilename.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(expectedFilename != actualFilename) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(StringFormat(EX_FILENAME_MISMATCH,
|
2010-01-05 16:01:46 +00:00
|
|
|
expectedFilename.c_str(),
|
|
|
|
actualFilename.c_str()).str());
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void RequestGroup::validateTotalLength(uint64_t expectedTotalLength,
|
2010-01-05 16:01:46 +00:00
|
|
|
uint64_t actualTotalLength) const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
|
|
|
if(expectedTotalLength <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(expectedTotalLength != actualTotalLength) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX
|
2008-04-27 02:22:14 +00:00
|
|
|
(StringFormat(EX_SIZE_MISMATCH,
|
2010-01-05 16:01:46 +00:00
|
|
|
util::itos(expectedTotalLength, true).c_str(),
|
|
|
|
util::itos(actualTotalLength, true).c_str()).str());
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void RequestGroup::validateFilename(const std::string& actualFilename) const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
validateFilename(_downloadContext->getFileEntries().front()->getBasename(), actualFilename);
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void RequestGroup::validateTotalLength(uint64_t actualTotalLength) const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
validateTotalLength(getTotalLength(), actualTotalLength);
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
void RequestGroup::increaseStreamConnection()
|
2007-06-04 12:52:57 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
++_numStreamConnection;
|
2007-06-05 11:37:25 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
void RequestGroup::decreaseStreamConnection()
|
2007-06-05 11:37:25 +00:00
|
|
|
{
|
2007-10-11 16:58:24 +00:00
|
|
|
--_numStreamConnection;
|
2007-06-04 12:52:57 +00:00
|
|
|
}
|
2007-08-28 15:46:49 +00:00
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int RequestGroup::getNumConnection() const
|
2007-08-28 15:46:49 +00:00
|
|
|
{
|
2008-03-09 12:24:01 +00:00
|
|
|
unsigned int numConnection = _numStreamConnection;
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2008-11-03 06:49:02 +00:00
|
|
|
if(!_btRuntime.isNull()) {
|
|
|
|
numConnection += _btRuntime->getConnections();
|
2007-08-28 15:46:49 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
return numConnection;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::increaseNumCommand()
|
|
|
|
{
|
|
|
|
++_numCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::decreaseNumCommand()
|
|
|
|
{
|
|
|
|
--_numCommand;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TransferStat RequestGroup::calculateStat()
|
|
|
|
{
|
|
|
|
TransferStat stat;
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2008-11-03 06:49:02 +00:00
|
|
|
if(!_peerStorage.isNull()) {
|
|
|
|
stat = _peerStorage->calculateStat();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
if(!_segmentMan.isNull()) {
|
|
|
|
stat.setDownloadSpeed(stat.getDownloadSpeed()+_segmentMan->calculateDownloadSpeed());
|
|
|
|
}
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
2009-05-09 04:11:31 +00:00
|
|
|
void RequestGroup::setHaltRequested(bool f, HaltReason haltReason)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
|
|
|
_haltRequested = f;
|
2009-05-09 04:11:31 +00:00
|
|
|
if(_haltRequested) {
|
|
|
|
_haltReason = haltReason;
|
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2008-11-03 06:49:02 +00:00
|
|
|
if(!_btRuntime.isNull()) {
|
|
|
|
_btRuntime->setHalt(f);
|
2007-08-28 15:46:49 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
}
|
|
|
|
|
2009-05-09 04:11:31 +00:00
|
|
|
void RequestGroup::setForceHaltRequested(bool f, HaltReason haltReason)
|
2007-12-07 13:33:59 +00:00
|
|
|
{
|
2009-05-09 04:11:31 +00:00
|
|
|
setHaltRequested(f, haltReason);
|
2007-12-07 13:33:59 +00:00
|
|
|
_forceHaltRequested = f;
|
|
|
|
}
|
|
|
|
|
2008-11-03 06:49:02 +00:00
|
|
|
void RequestGroup::releaseRuntimeResource(DownloadEngine* e)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-11-26 13:16:02 +00:00
|
|
|
e->getBtRegistry()->remove(_gid);
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
if(!_pieceStorage.isNull()) {
|
|
|
|
_pieceStorage->removeAdvertisedPiece(0);
|
|
|
|
}
|
2009-07-05 09:10:08 +00:00
|
|
|
_downloadContext->releaseRuntimeResource();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
void RequestGroup::preDownloadProcessing()
|
|
|
|
{
|
2009-06-28 10:37:15 +00:00
|
|
|
_logger->debug("Finding PreDownloadHandler for path %s.",
|
2010-01-05 16:01:46 +00:00
|
|
|
getFirstFilePath().c_str());
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
try {
|
|
|
|
for(PreDownloadHandlers::const_iterator itr = _preDownloadHandlers.begin();
|
2010-01-05 16:01:46 +00:00
|
|
|
itr != _preDownloadHandlers.end(); ++itr) {
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
if((*itr)->canHandle(this)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
(*itr)->execute(this);
|
|
|
|
return;
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(RecoverableException& ex) {
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
_logger->error(EX_EXCEPTION_CAUGHT, ex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_logger->debug("No PreDownloadHandler found.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-11 13:59:27 +00:00
|
|
|
void RequestGroup::postDownloadProcessing
|
|
|
|
(std::deque<SharedHandle<RequestGroup> >& groups)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2009-06-28 10:37:15 +00:00
|
|
|
_logger->debug("Finding PostDownloadHandler for path %s.",
|
2010-01-05 16:01:46 +00:00
|
|
|
getFirstFilePath().c_str());
|
2007-10-15 14:55:24 +00:00
|
|
|
try {
|
|
|
|
for(PostDownloadHandlers::const_iterator itr = _postDownloadHandlers.begin();
|
2010-01-05 16:01:46 +00:00
|
|
|
itr != _postDownloadHandlers.end(); ++itr) {
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
if((*itr)->canHandle(this)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
(*itr)->getNextRequestGroups(groups, this);
|
|
|
|
return;
|
2007-10-15 14:55:24 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(RecoverableException& ex) {
|
2007-10-15 14:55:24 +00:00
|
|
|
_logger->error(EX_EXCEPTION_CAUGHT, ex);
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2007-10-15 13:22:02 +00:00
|
|
|
_logger->debug("No PostDownloadHandler found.");
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
void RequestGroup::initializePreDownloadHandler()
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
if(_option->get(PREF_FOLLOW_TORRENT) == V_MEM) {
|
|
|
|
_preDownloadHandlers.push_back(DownloadHandlerFactory::getBtPreDownloadHandler());
|
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
|
|
|
if(_option->get(PREF_FOLLOW_METALINK) == V_MEM) {
|
|
|
|
_preDownloadHandlers.push_back(DownloadHandlerFactory::getMetalinkPreDownloadHandler());
|
|
|
|
}
|
|
|
|
#endif // ENABLE_METALINK
|
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
void RequestGroup::initializePostDownloadHandler()
|
|
|
|
{
|
2007-11-14 10:10:38 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2008-05-18 10:25:41 +00:00
|
|
|
if(_option->getAsBool(PREF_FOLLOW_TORRENT) ||
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
_option->get(PREF_FOLLOW_TORRENT) == V_MEM) {
|
|
|
|
_postDownloadHandlers.push_back(DownloadHandlerFactory::getBtPostDownloadHandler());
|
2007-11-18 11:59:42 +00:00
|
|
|
}
|
2007-11-14 10:10:38 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
2008-05-18 10:25:41 +00:00
|
|
|
if(_option->getAsBool(PREF_FOLLOW_METALINK) ||
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
_option->get(PREF_FOLLOW_METALINK) == V_MEM) {
|
|
|
|
_postDownloadHandlers.push_back(DownloadHandlerFactory::getMetalinkPostDownloadHandler());
|
2007-11-18 11:59:42 +00:00
|
|
|
}
|
2007-11-14 10:10:38 +00:00
|
|
|
#endif // ENABLE_METALINK
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RequestGroup::isDependencyResolved()
|
|
|
|
{
|
|
|
|
if(_dependency.isNull()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return _dependency->resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::setSegmentManFactory(const SegmentManFactoryHandle& segmentManFactory)
|
|
|
|
{
|
|
|
|
_segmentManFactory = segmentManFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::dependsOn(const DependencyHandle& dep)
|
|
|
|
{
|
|
|
|
_dependency = dep;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::setDiskWriterFactory(const DiskWriterFactoryHandle& diskWriterFactory)
|
|
|
|
{
|
|
|
|
_diskWriterFactory = diskWriterFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::addPostDownloadHandler(const PostDownloadHandlerHandle& handler)
|
|
|
|
{
|
|
|
|
_postDownloadHandlers.push_back(handler);
|
|
|
|
}
|
|
|
|
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
void RequestGroup::addPreDownloadHandler(const PreDownloadHandlerHandle& handler)
|
|
|
|
{
|
|
|
|
_preDownloadHandlers.push_back(handler);
|
|
|
|
}
|
|
|
|
|
2009-11-23 13:17:48 +00:00
|
|
|
void RequestGroup::clearPostDownloadHandler()
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
|
|
|
_postDownloadHandlers.clear();
|
|
|
|
}
|
|
|
|
|
2009-11-23 13:17:48 +00:00
|
|
|
void RequestGroup::clearPreDownloadHandler()
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
{
|
|
|
|
_preDownloadHandlers.clear();
|
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
void RequestGroup::setPieceStorage(const PieceStorageHandle& pieceStorage)
|
|
|
|
{
|
|
|
|
_pieceStorage = pieceStorage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::setProgressInfoFile(const BtProgressInfoFileHandle& progressInfoFile)
|
|
|
|
{
|
|
|
|
_progressInfoFile = progressInfoFile;
|
2007-08-28 15:46:49 +00:00
|
|
|
}
|
2007-10-29 12:43:45 +00:00
|
|
|
|
|
|
|
bool RequestGroup::needsFileAllocation() const
|
|
|
|
{
|
|
|
|
return isFileAllocationEnabled() &&
|
2008-03-09 12:24:01 +00:00
|
|
|
(uint64_t)_option->getAsLLInt(PREF_NO_FILE_ALLOCATION_LIMIT) <= getTotalLength() &&
|
2007-10-29 12:43:45 +00:00
|
|
|
!_pieceStorage->getDiskAdaptor()->fileAllocationIterator()->finished();
|
|
|
|
}
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
|
|
|
|
DownloadResultHandle RequestGroup::createDownloadResult() const
|
|
|
|
{
|
2008-11-10 16:10:31 +00:00
|
|
|
uint64_t sessionDownloadLength = 0;
|
|
|
|
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
if(!_peerStorage.isNull()) {
|
2009-01-31 13:01:25 +00:00
|
|
|
sessionDownloadLength +=
|
2008-11-10 16:10:31 +00:00
|
|
|
_peerStorage->calculateStat().getSessionDownloadLength();
|
2009-01-31 13:01:25 +00:00
|
|
|
}
|
2008-11-10 16:10:31 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2009-01-31 13:01:25 +00:00
|
|
|
if(!_segmentMan.isNull()) {
|
|
|
|
sessionDownloadLength +=
|
|
|
|
_segmentMan->calculateSessionDownloadLength();
|
|
|
|
}
|
2008-04-20 00:50:22 +00:00
|
|
|
return
|
2008-11-10 16:10:31 +00:00
|
|
|
SharedHandle<DownloadResult>
|
|
|
|
(new DownloadResult(_gid,
|
2010-01-05 16:01:46 +00:00
|
|
|
_downloadContext->getFileEntries(),
|
|
|
|
_inMemoryDownload,
|
|
|
|
sessionDownloadLength,
|
|
|
|
_downloadContext->calculateSessionTime(),
|
|
|
|
downloadResult(),
|
|
|
|
_followedByGIDs,
|
|
|
|
_belongsToGID));
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
}
|
2007-12-12 13:53:33 +00:00
|
|
|
|
2007-12-29 07:02:35 +00:00
|
|
|
void RequestGroup::reportDownloadFinished()
|
|
|
|
{
|
|
|
|
_logger->notice(MSG_FILE_DOWNLOAD_COMPLETED,
|
2010-01-05 16:01:46 +00:00
|
|
|
_downloadContext->getBasePath().c_str());
|
2009-01-06 13:13:42 +00:00
|
|
|
_uriSelector->resetCounters();
|
2007-12-29 07:02:35 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-06-28 10:37:15 +00:00
|
|
|
if(_downloadContext->hasAttribute(bittorrent::BITTORRENT)) {
|
2008-09-19 14:15:06 +00:00
|
|
|
TransferStat stat = calculateStat();
|
2009-11-23 13:17:48 +00:00
|
|
|
double shareRatio =
|
|
|
|
((stat.getAllTimeUploadLength()*10)/getCompletedLength())/10.0;
|
|
|
|
const BDE& attrs = _downloadContext->getAttribute(bittorrent::BITTORRENT);
|
|
|
|
if(attrs.containsKey(bittorrent::METADATA)) {
|
|
|
|
_logger->notice(MSG_SHARE_RATIO_REPORT,
|
2010-01-05 16:01:46 +00:00
|
|
|
shareRatio,
|
|
|
|
util::abbrevSize(stat.getAllTimeUploadLength()).c_str(),
|
|
|
|
util::abbrevSize(getCompletedLength()).c_str());
|
2009-11-23 13:17:48 +00:00
|
|
|
}
|
2007-12-29 07:02:35 +00:00
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2008-05-05 08:25:41 +00:00
|
|
|
void RequestGroup::addAcceptType(const std::string& type)
|
|
|
|
{
|
|
|
|
if(std::find(_acceptTypes.begin(), _acceptTypes.end(), type) == _acceptTypes.end()) {
|
|
|
|
_acceptTypes.push_back(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::removeAcceptType(const std::string& type)
|
|
|
|
{
|
|
|
|
_acceptTypes.erase(std::remove(_acceptTypes.begin(), _acceptTypes.end(), type),
|
2010-01-05 16:01:46 +00:00
|
|
|
_acceptTypes.end());
|
2008-05-05 08:25:41 +00:00
|
|
|
}
|
|
|
|
|
2008-08-04 17:06:47 +00:00
|
|
|
void RequestGroup::setURISelector(const SharedHandle<URISelector>& uriSelector)
|
|
|
|
{
|
|
|
|
_uriSelector = uriSelector;
|
|
|
|
}
|
|
|
|
|
2008-09-07 14:38:26 +00:00
|
|
|
void RequestGroup::applyLastModifiedTimeToLocalFiles()
|
|
|
|
{
|
|
|
|
if(!_pieceStorage.isNull() && _lastModifiedTime.good()) {
|
|
|
|
time_t t = _lastModifiedTime.getTime();
|
2008-09-08 13:09:38 +00:00
|
|
|
_logger->info("Applying Last-Modified time: %s in local time zone",
|
2010-01-05 16:01:46 +00:00
|
|
|
ctime(&t));
|
2008-09-07 14:38:26 +00:00
|
|
|
size_t n =
|
|
|
|
_pieceStorage->getDiskAdaptor()->utime(Time(), _lastModifiedTime);
|
2008-10-01 15:16:36 +00:00
|
|
|
_logger->info("Last-Modified attrs of %lu files were updated.",
|
2010-01-05 16:01:46 +00:00
|
|
|
static_cast<unsigned long>(n));
|
2008-09-07 14:38:26 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-10 14:56:44 +00:00
|
|
|
|
2008-09-07 14:38:26 +00:00
|
|
|
void RequestGroup::updateLastModifiedTime(const Time& time)
|
|
|
|
{
|
|
|
|
if(time.good() && _lastModifiedTime < time) {
|
|
|
|
_lastModifiedTime = time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-10 14:56:44 +00:00
|
|
|
void RequestGroup::increaseAndValidateFileNotFoundCount()
|
|
|
|
{
|
|
|
|
++_fileNotFoundCount;
|
|
|
|
const unsigned int maxCount = _option->getAsInt(PREF_MAX_FILE_NOT_FOUND);
|
|
|
|
if(maxCount > 0 && _fileNotFoundCount >= maxCount &&
|
2010-01-25 12:48:47 +00:00
|
|
|
(_segmentMan.isNull() ||
|
|
|
|
_segmentMan->calculateSessionDownloadLength() == 0)) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2009-01-12 12:27:34 +00:00
|
|
|
(StringFormat("Reached max-file-not-found count=%u", maxCount).str(),
|
2009-06-29 08:42:58 +00:00
|
|
|
downloadresultcode::MAX_FILE_NOT_FOUND);
|
2008-09-10 14:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 12:02:16 +00:00
|
|
|
void RequestGroup::markInMemoryDownload()
|
|
|
|
{
|
|
|
|
_inMemoryDownload = true;
|
|
|
|
}
|
|
|
|
|
2009-02-01 02:55:44 +00:00
|
|
|
void RequestGroup::setTimeout(time_t timeout)
|
|
|
|
{
|
|
|
|
_timeout = timeout;
|
|
|
|
}
|
|
|
|
|
2009-02-28 11:48:26 +00:00
|
|
|
bool RequestGroup::doesDownloadSpeedExceed()
|
|
|
|
{
|
|
|
|
return _maxDownloadSpeedLimit > 0 &&
|
|
|
|
_maxDownloadSpeedLimit < calculateStat().getDownloadSpeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RequestGroup::doesUploadSpeedExceed()
|
|
|
|
{
|
|
|
|
return _maxUploadSpeedLimit > 0 &&
|
|
|
|
_maxUploadSpeedLimit < calculateStat().getUploadSpeed();
|
|
|
|
}
|
|
|
|
|
2009-06-29 08:42:58 +00:00
|
|
|
void RequestGroup::setLastUriResult
|
|
|
|
(const std::string uri, downloadresultcode::RESULT result)
|
|
|
|
{
|
|
|
|
_lastUriResult.reset(new URIResult(uri, result));
|
|
|
|
}
|
|
|
|
|
2009-10-05 13:35:09 +00:00
|
|
|
void RequestGroup::saveControlFile() const
|
|
|
|
{
|
|
|
|
if(_saveControlFile) {
|
|
|
|
_progressInfoFile->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::removeControlFile() const
|
|
|
|
{
|
|
|
|
_progressInfoFile->removeFile();
|
|
|
|
}
|
|
|
|
|
2009-11-28 10:12:04 +00:00
|
|
|
void RequestGroup::setDownloadContext
|
|
|
|
(const SharedHandle<DownloadContext>& downloadContext)
|
|
|
|
{
|
|
|
|
_downloadContext = downloadContext;
|
|
|
|
if(!_downloadContext.isNull()) {
|
|
|
|
_downloadContext->setOwnerRequestGroup(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-10 07:51:45 +00:00
|
|
|
int32_t RequestGroup::newGID()
|
|
|
|
{
|
|
|
|
if(_gidCounter == INT32_MAX) {
|
|
|
|
_gidCounter = 0;
|
|
|
|
}
|
|
|
|
return ++_gidCounter;
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|