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"
|
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"
|
2010-11-20 08:21:36 +00:00
|
|
|
#include "fmt.h"
|
2008-05-13 14:15:23 +00:00
|
|
|
#include "A2STR.h"
|
2008-08-04 17:06:47 +00:00
|
|
|
#include "URISelector.h"
|
2011-06-11 12:49:09 +00:00
|
|
|
#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"
|
2010-06-12 13:49:39 +00:00
|
|
|
#include "Segment.h"
|
2011-01-16 07:55:41 +00:00
|
|
|
#include "SocketRecvBuffer.h"
|
2007-07-04 16:04:57 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2007-10-11 16:58:24 +00:00
|
|
|
# include "CheckIntegrityCommand.h"
|
2010-06-22 11:57:31 +00:00
|
|
|
# include "ChecksumCheckIntegrityEntry.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 "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"
|
2010-08-07 14:15:21 +00:00
|
|
|
# include "DHTNode.h"
|
|
|
|
# include "DHTRoutingTable.h"
|
|
|
|
# include "DHTTaskQueue.h"
|
|
|
|
# include "DHTTaskFactory.h"
|
|
|
|
# include "DHTTokenTracker.h"
|
|
|
|
# include "DHTMessageDispatcher.h"
|
|
|
|
# include "DHTMessageReceiver.h"
|
|
|
|
# include "DHTMessageFactory.h"
|
|
|
|
# include "DHTMessageCallback.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"
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
# include "bittorrent_helper.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
|
|
|
|
2011-03-17 03:17:46 +00:00
|
|
|
a2_gid_t RequestGroup::gidCounter_ = 0;
|
2007-10-11 16:58:24 +00:00
|
|
|
|
2010-11-20 08:21:36 +00:00
|
|
|
RequestGroup::RequestGroup(const SharedHandle<Option>& option)
|
|
|
|
: gid_(newGID()),
|
|
|
|
option_(new Option(*option.get())),
|
|
|
|
numConcurrentCommand_(option->getAsInt(PREF_SPLIT)),
|
|
|
|
numStreamConnection_(0),
|
|
|
|
numStreamCommand_(0),
|
|
|
|
numCommand_(0),
|
|
|
|
saveControlFile_(true),
|
|
|
|
progressInfoFile_(new NullProgressInfoFile()),
|
|
|
|
preLocalFileCheckEnabled_(true),
|
|
|
|
haltRequested_(false),
|
|
|
|
forceHaltRequested_(false),
|
|
|
|
haltReason_(RequestGroup::NONE),
|
|
|
|
pauseRequested_(false),
|
2011-06-11 12:49:09 +00:00
|
|
|
uriSelector_(new InorderURISelector()),
|
2010-11-20 08:21:36 +00:00
|
|
|
lastModifiedTime_(Time::null()),
|
|
|
|
fileNotFoundCount_(0),
|
|
|
|
timeout_(option->getAsInt(PREF_TIMEOUT)),
|
2010-11-12 12:48:48 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-11-20 08:21:36 +00:00
|
|
|
btRuntime_(0),
|
|
|
|
peerStorage_(0),
|
2010-11-12 12:48:48 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2010-11-20 08:21:36 +00:00
|
|
|
inMemoryDownload_(false),
|
|
|
|
maxDownloadSpeedLimit_(option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)),
|
|
|
|
maxUploadSpeedLimit_(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)),
|
2010-11-28 08:00:30 +00:00
|
|
|
lastErrorCode_(error_code::UNDEFINED),
|
2010-11-20 08:21:36 +00:00
|
|
|
belongsToGID_(0),
|
|
|
|
requestGroupMan_(0),
|
|
|
|
resumeFailureCount_(0)
|
2010-06-21 13:51:56 +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.
|
2010-02-25 14:40:18 +00:00
|
|
|
// The mime types of Metalink is used for `transparent metalink'.
|
|
|
|
addAcceptType(DownloadHandlerConstants::getMetalinkContentTypes().begin(),
|
|
|
|
DownloadHandlerConstants::getMetalinkContentTypes().end());
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!option_->getAsBool(PREF_DRY_RUN)) {
|
2009-03-08 10:20:42 +00:00
|
|
|
initializePreDownloadHandler();
|
|
|
|
initializePostDownloadHandler();
|
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
RequestGroup::~RequestGroup() {}
|
|
|
|
|
2010-09-15 11:46:25 +00:00
|
|
|
bool RequestGroup::isCheckIntegrityReady() const
|
|
|
|
{
|
|
|
|
return option_->getAsBool(PREF_CHECK_INTEGRITY) &&
|
|
|
|
(downloadContext_->isChecksumVerificationAvailable() ||
|
|
|
|
downloadContext_->isPieceHashVerificationAvailable());
|
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
bool RequestGroup::downloadFinished() const
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!pieceStorage_) {
|
2007-10-11 16:58:24 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
return pieceStorage_->downloadFinished();
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-29 14:06:59 +00:00
|
|
|
bool RequestGroup::allDownloadFinished() const
|
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!pieceStorage_) {
|
2007-10-29 14:06:59 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
return pieceStorage_->allDownloadFinished();
|
2007-10-29 14:06:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-28 07:52:02 +00:00
|
|
|
error_code::Value RequestGroup::downloadResult() const
|
2009-01-12 12:27:34 +00:00
|
|
|
{
|
2010-06-22 11:57:31 +00:00
|
|
|
if(downloadFinished() && !downloadContext_->isChecksumVerificationNeeded())
|
2010-11-28 07:52:02 +00:00
|
|
|
return error_code::FINISHED;
|
2009-01-12 12:27:34 +00:00
|
|
|
else {
|
2011-05-29 11:59:45 +00:00
|
|
|
if(haltReason_ == RequestGroup::USER_REQUEST) {
|
|
|
|
return error_code::REMOVED;
|
|
|
|
} else if(lastErrorCode_ == error_code::UNDEFINED) {
|
|
|
|
if(haltReason_ == RequestGroup::SHUTDOWN_SIGNAL) {
|
2010-11-28 07:52:02 +00:00
|
|
|
return error_code::IN_PROGRESS;
|
2009-05-09 04:11:31 +00:00
|
|
|
} else {
|
2010-11-28 07:52:02 +00:00
|
|
|
return error_code::UNKNOWN_ERROR;
|
2009-05-09 04:11:31 +00:00
|
|
|
}
|
2009-01-12 12:27:34 +00:00
|
|
|
} else {
|
2010-11-28 08:00:30 +00:00
|
|
|
return lastErrorCode_;
|
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
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(pieceStorage_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->closeFile();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2007-05-20 13:57:56 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 11:46:25 +00:00
|
|
|
// TODO The function name is not intuitive at all.. it does not convey
|
|
|
|
// that this function open file.
|
|
|
|
SharedHandle<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
|
|
|
|
{
|
|
|
|
BtProgressInfoFileHandle infoFile
|
|
|
|
(new DefaultBtProgressInfoFile(downloadContext_, pieceStorage_,
|
|
|
|
option_.get()));
|
|
|
|
SharedHandle<CheckIntegrityEntry> checkEntry;
|
|
|
|
if(option_->getAsBool(PREF_CHECK_INTEGRITY) &&
|
|
|
|
downloadContext_->isPieceHashVerificationAvailable()) {
|
|
|
|
// When checking piece hash, we don't care file is downloaded and
|
|
|
|
// infoFile exists.
|
|
|
|
loadAndOpenFile(infoFile);
|
|
|
|
checkEntry.reset(new StreamCheckIntegrityEntry(this));
|
|
|
|
} else if(infoFile->exists()) {
|
|
|
|
loadAndOpenFile(infoFile);
|
|
|
|
if(downloadFinished()) {
|
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
|
|
|
if(downloadContext_->isChecksumVerificationNeeded()) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_INFO(MSG_HASH_CHECK_NOT_DONE);
|
2010-11-15 12:02:54 +00:00
|
|
|
ChecksumCheckIntegrityEntry* tempEntry =
|
|
|
|
new ChecksumCheckIntegrityEntry(this);
|
2010-09-15 11:46:25 +00:00
|
|
|
tempEntry->setRedownload(true);
|
2010-11-15 12:02:54 +00:00
|
|
|
checkEntry.reset(tempEntry);
|
2010-09-15 11:46:25 +00:00
|
|
|
} else
|
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
|
|
|
{
|
|
|
|
downloadContext_->setChecksumVerified(true);
|
2011-08-04 12:43:02 +00:00
|
|
|
A2_LOG_NOTICE
|
|
|
|
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
|
|
|
util::itos(gid_).c_str(),
|
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
2010-09-15 11:46:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
checkEntry.reset(new StreamCheckIntegrityEntry(this));
|
|
|
|
}
|
|
|
|
} else if(downloadFinishedByFileLength()) {
|
|
|
|
pieceStorage_->markAllPiecesDone();
|
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
|
|
|
if(option_->getAsBool(PREF_CHECK_INTEGRITY) &&
|
|
|
|
downloadContext_->isChecksumVerificationAvailable()) {
|
|
|
|
loadAndOpenFile(infoFile);
|
2010-11-15 12:02:54 +00:00
|
|
|
ChecksumCheckIntegrityEntry* tempEntry =
|
|
|
|
new ChecksumCheckIntegrityEntry(this);
|
2010-09-15 11:46:25 +00:00
|
|
|
tempEntry->setRedownload(true);
|
2010-11-15 12:02:54 +00:00
|
|
|
checkEntry.reset(tempEntry);
|
2010-09-15 11:46:25 +00:00
|
|
|
} else
|
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
|
|
|
{
|
|
|
|
downloadContext_->setChecksumVerified(true);
|
2011-08-04 12:43:02 +00:00
|
|
|
A2_LOG_NOTICE
|
|
|
|
(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
|
|
|
|
util::itos(gid_).c_str(),
|
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
2010-09-15 11:46:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
loadAndOpenFile(infoFile);
|
|
|
|
checkEntry.reset(new StreamCheckIntegrityEntry(this));
|
|
|
|
}
|
|
|
|
return checkEntry;
|
|
|
|
}
|
|
|
|
|
2009-11-23 13:17:48 +00:00
|
|
|
void RequestGroup::createInitialCommand
|
2010-02-28 12:30:11 +00:00
|
|
|
(std::vector<Command*>& commands, DownloadEngine* e)
|
2007-05-20 13:57:56 +00:00
|
|
|
{
|
2010-07-10 07:34:20 +00:00
|
|
|
// Start session timer here. When file size becomes known, it will
|
|
|
|
// be reset again in *FileAllocationEntry, because hash check and
|
|
|
|
// file allocation takes a time. For downloads in which file size
|
|
|
|
// is unknown, session timer will not be reset.
|
|
|
|
downloadContext_->resetDownloadStartTime();
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
|
2010-06-18 14:47:09 +00:00
|
|
|
SharedHandle<TorrentAttribute> torrentAttrs =
|
2010-06-21 13:51:56 +00:00
|
|
|
bittorrent::getTorrentAttrs(downloadContext_);
|
2010-06-18 14:47:09 +00:00
|
|
|
bool metadataGetMode = torrentAttrs->metadata.empty();
|
2010-06-21 13:51:56 +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();
|
2010-11-12 12:48:48 +00:00
|
|
|
if(btRegistry->getDownloadContext(torrentAttrs->infoHash)) {
|
2010-02-26 15:37:08 +00:00
|
|
|
// TODO If metadataGetMode == false and each FileEntry has
|
|
|
|
// URI, then go without BT.
|
2010-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt("InfoHash %s is already registered.",
|
2010-11-28 08:29:32 +00:00
|
|
|
bittorrent::getInfoHashString(downloadContext_).c_str()),
|
|
|
|
error_code::DUPLICATE_INFO_HASH);
|
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-06-08 14:11:36 +00:00
|
|
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
2010-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
2010-11-28 08:29:32 +00:00
|
|
|
error_code::DUPLICATE_DOWNLOAD);
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
|
|
|
initPieceStorage();
|
2010-06-21 13:51:56 +00:00
|
|
|
if(downloadContext_->getFileEntries().size() > 1) {
|
|
|
|
pieceStorage_->setupFileFilter();
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
2007-11-21 16:14:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 13:17:48 +00:00
|
|
|
SharedHandle<DefaultBtProgressInfoFile> progressInfoFile;
|
|
|
|
if(!metadataGetMode) {
|
2010-06-21 13:51:56 +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());
|
2010-06-21 13:51:56 +00:00
|
|
|
btRuntime->setMaxPeers(option_->getAsInt(PREF_BT_MAX_PEERS));
|
2010-11-12 12:48:48 +00:00
|
|
|
btRuntime_ = btRuntime.get();
|
|
|
|
if(progressInfoFile) {
|
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
|
|
|
|
2010-06-12 08:50:50 +00:00
|
|
|
SharedHandle<DefaultPeerStorage> peerStorage(new DefaultPeerStorage());
|
2008-11-03 06:49:02 +00:00
|
|
|
peerStorage->setBtRuntime(btRuntime);
|
2010-06-21 13:51:56 +00:00
|
|
|
peerStorage->setPieceStorage(pieceStorage_);
|
2010-11-12 12:48:48 +00:00
|
|
|
peerStorage_ = peerStorage.get();
|
|
|
|
if(progressInfoFile) {
|
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-06-21 13:51:56 +00:00
|
|
|
(new DefaultBtAnnounce(downloadContext_, option_.get()));
|
2008-11-03 06:49:02 +00:00
|
|
|
btAnnounce->setBtRuntime(btRuntime);
|
2010-06-21 13:51:56 +00:00
|
|
|
btAnnounce->setPieceStorage(pieceStorage_);
|
2008-11-03 06:49:02 +00:00
|
|
|
btAnnounce->setPeerStorage(peerStorage);
|
2009-03-20 13:44:03 +00:00
|
|
|
btAnnounce->setUserDefinedInterval
|
2010-06-21 13:51:56 +00:00
|
|
|
(option_->getAsInt(PREF_BT_TRACKER_INTERVAL));
|
2007-10-11 16:58:24 +00:00
|
|
|
btAnnounce->shuffleAnnounce();
|
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
assert(btRegistry->get(gid_).isNull());
|
2010-11-12 12:48:48 +00:00
|
|
|
btRegistry->put
|
|
|
|
(gid_, BtObject
|
|
|
|
(downloadContext_,
|
|
|
|
pieceStorage_,
|
|
|
|
peerStorage,
|
|
|
|
btAnnounce,
|
|
|
|
btRuntime,
|
|
|
|
(progressInfoFile ?
|
|
|
|
SharedHandle<BtProgressInfoFile>(progressInfoFile) :
|
|
|
|
progressInfoFile_)));
|
2009-11-23 13:17:48 +00:00
|
|
|
if(metadataGetMode) {
|
2010-08-07 14:15:21 +00:00
|
|
|
if(option_->getAsBool(PREF_ENABLE_DHT) ||
|
2010-08-27 11:48:09 +00:00
|
|
|
(!e->getOption()->getAsBool(PREF_DISABLE_IPV6) &&
|
|
|
|
option_->getAsBool(PREF_ENABLE_DHT6))) {
|
2010-08-07 14:15:21 +00:00
|
|
|
if(option_->getAsBool(PREF_ENABLE_DHT)) {
|
|
|
|
std::vector<Command*> dhtCommands;
|
|
|
|
DHTSetup().setup(dhtCommands, e, AF_INET);
|
|
|
|
e->addCommand(dhtCommands);
|
|
|
|
}
|
2010-08-27 11:48:09 +00:00
|
|
|
if(!e->getOption()->getAsBool(PREF_DISABLE_IPV6) &&
|
|
|
|
option_->getAsBool(PREF_ENABLE_DHT6)) {
|
2010-08-07 14:15:21 +00:00
|
|
|
std::vector<Command*> dhtCommands;
|
|
|
|
DHTSetup().setup(dhtCommands, e, AF_INET6);
|
|
|
|
e->addCommand(dhtCommands);
|
|
|
|
}
|
2010-01-05 16:01:46 +00:00
|
|
|
} else {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_NOTICE("For BitTorrent Magnet URI, enabling DHT is strongly"
|
|
|
|
" recommended. See --enable-dht option.");
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SharedHandle<CheckIntegrityEntry> entry
|
|
|
|
(new BtCheckIntegrityEntry(this));
|
|
|
|
entry->onDownloadIncomplete(commands, e);
|
|
|
|
|
|
|
|
return;
|
2009-11-23 13:17:48 +00:00
|
|
|
}
|
2010-02-26 15:37:08 +00:00
|
|
|
removeDefunctControlFile(progressInfoFile);
|
2009-05-04 07:50:38 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
uint64_t actualFileSize = pieceStorage_->getDiskAdaptor()->size();
|
|
|
|
if(actualFileSize == downloadContext_->getTotalLength()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
// First, make DiskAdaptor read-only mode to allow the
|
|
|
|
// program to seed file in read-only media.
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->enableReadOnly();
|
2010-01-05 16:01:46 +00:00
|
|
|
} else {
|
|
|
|
// Open file in writable mode to allow the program
|
2010-06-21 13:51:56 +00:00
|
|
|
// truncate the file to downloadContext_->getTotalLength()
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG
|
|
|
|
(fmt("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()));
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
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();
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openFile();
|
2007-08-28 15:46:49 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(pieceStorage_->getDiskAdaptor()->fileExists()) {
|
|
|
|
if(!option_->getAsBool(PREF_CHECK_INTEGRITY) &&
|
|
|
|
!option_->getAsBool(PREF_ALLOW_OVERWRITE) &&
|
|
|
|
!option_->getAsBool(PREF_BT_SEED_UNVERIFIED)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
// TODO we need this->haltRequested = true?
|
2010-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt(MSG_FILE_ALREADY_EXISTS,
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
2010-11-28 08:29:32 +00:00
|
|
|
error_code::FILE_ALREADY_EXISTS);
|
2010-01-05 16:01:46 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openFile();
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->getAsBool(PREF_BT_SEED_UNVERIFIED)) {
|
|
|
|
pieceStorage_->markAllPiecesDone();
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openFile();
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
2007-08-28 15:46:49 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
progressInfoFile_ = progressInfoFile;
|
2009-05-04 07:50:38 +00:00
|
|
|
|
2010-08-07 14:15:21 +00:00
|
|
|
if(!torrentAttrs->privateTorrent &&
|
|
|
|
(option_->getAsBool(PREF_ENABLE_DHT) ||
|
2010-08-27 11:48:09 +00:00
|
|
|
(!e->getOption()->getAsBool(PREF_DISABLE_IPV6) &&
|
|
|
|
option_->getAsBool(PREF_ENABLE_DHT6)))) {
|
2010-08-07 14:15:21 +00:00
|
|
|
if(option_->getAsBool(PREF_ENABLE_DHT)) {
|
|
|
|
std::vector<Command*> dhtCommands;
|
|
|
|
DHTSetup().setup(dhtCommands, e, AF_INET);
|
|
|
|
e->addCommand(dhtCommands);
|
|
|
|
}
|
2010-08-27 11:48:09 +00:00
|
|
|
if(!e->getOption()->getAsBool(PREF_DISABLE_IPV6) &&
|
|
|
|
option_->getAsBool(PREF_ENABLE_DHT6)) {
|
2010-08-07 14:15:21 +00:00
|
|
|
std::vector<Command*> dhtCommands;
|
|
|
|
DHTSetup().setup(dhtCommands, e, AF_INET6);
|
|
|
|
e->addCommand(dhtCommands);
|
|
|
|
}
|
2010-06-18 14:47:09 +00:00
|
|
|
const std::vector<std::pair<std::string, uint16_t> >& nodes =
|
|
|
|
torrentAttrs->nodes;
|
2010-08-07 14:15:21 +00:00
|
|
|
// TODO Are nodes in torrent IPv4 only?
|
|
|
|
if(!nodes.empty() && DHTRegistry::isInitialized()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
DHTEntryPointNameResolveCommand* command =
|
2010-08-07 14:15:21 +00:00
|
|
|
new DHTEntryPointNameResolveCommand(e->newCUID(), e, nodes);
|
2010-06-13 02:53:11 +00:00
|
|
|
command->setTaskQueue(DHTRegistry::getData().taskQueue);
|
|
|
|
command->setTaskFactory(DHTRegistry::getData().taskFactory);
|
|
|
|
command->setRoutingTable(DHTRegistry::getData().routingTable);
|
|
|
|
command->setLocalNode(DHTRegistry::getData().localNode);
|
2010-06-08 14:11:36 +00:00
|
|
|
e->addCommand(command);
|
2010-01-05 16:01:46 +00:00
|
|
|
}
|
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
|
|
|
}
|
2010-02-28 12:30:11 +00:00
|
|
|
SharedHandle<CheckIntegrityEntry> 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.
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->getAsBool(PREF_BT_SEED_UNVERIFIED) &&
|
|
|
|
pieceStorage_->downloadFinished()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
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
|
2010-06-21 13:51:56 +00:00
|
|
|
if(downloadContext_->getFileEntries().size() == 1) {
|
2010-02-26 15:37:08 +00:00
|
|
|
// TODO I assume here when totallength is set to DownloadContext and it is
|
|
|
|
// not 0, then filepath is also set DownloadContext correctly....
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->getAsBool(PREF_DRY_RUN) ||
|
|
|
|
downloadContext_->getTotalLength() == 0) {
|
2010-02-26 15:37:08 +00:00
|
|
|
createNextCommand(commands, e, 1);
|
2010-09-15 11:46:25 +00:00
|
|
|
} else {
|
2010-06-08 14:11:36 +00:00
|
|
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
2010-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
2010-11-28 08:29:32 +00:00
|
|
|
error_code::DUPLICATE_DOWNLOAD);
|
2010-02-26 15:37:08 +00:00
|
|
|
}
|
2010-11-11 05:12:37 +00:00
|
|
|
SharedHandle<BtProgressInfoFile> progressInfoFile
|
|
|
|
(new DefaultBtProgressInfoFile
|
|
|
|
(downloadContext_, SharedHandle<PieceStorage>(), option_.get()));
|
|
|
|
adjustFilename(progressInfoFile);
|
2010-02-26 15:37:08 +00:00
|
|
|
initPieceStorage();
|
2010-09-15 11:46:25 +00:00
|
|
|
SharedHandle<CheckIntegrityEntry> checkEntry =
|
|
|
|
createCheckIntegrityEntry();
|
2010-11-12 12:48:48 +00:00
|
|
|
if(checkEntry) {
|
2010-09-15 11:46:25 +00:00
|
|
|
processCheckIntegrityEntry(commands, checkEntry, e);
|
2010-02-26 15:37:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2010-09-15 12:15:54 +00:00
|
|
|
// TODO --dry-run is not supported for multifile download for now.
|
|
|
|
if(option_->getAsBool(PREF_DRY_RUN)) {
|
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION
|
|
|
|
("--dry-run in multi-file download is not supported yet.");
|
|
|
|
}
|
2010-09-15 11:46:25 +00:00
|
|
|
// TODO file size is known in this context?
|
|
|
|
|
2010-02-26 15:37:08 +00:00
|
|
|
// In this context, multiple FileEntry objects are in
|
|
|
|
// DownloadContext.
|
2010-06-08 14:11:36 +00:00
|
|
|
if(e->getRequestGroupMan()->isSameFileBeingDownloaded(this)) {
|
2010-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt(EX_DUPLICATE_FILE_DOWNLOAD,
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
2010-11-28 08:29:32 +00:00
|
|
|
error_code::DUPLICATE_DOWNLOAD);
|
2007-11-13 11:46:58 +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
|
|
|
initPieceStorage();
|
2010-06-21 13:51:56 +00:00
|
|
|
if(downloadContext_->getFileEntries().size() > 1) {
|
|
|
|
pieceStorage_->setupFileFilter();
|
2010-02-26 15:37:08 +00:00
|
|
|
}
|
|
|
|
SharedHandle<DefaultBtProgressInfoFile> progressInfoFile
|
2010-06-21 13:51:56 +00:00
|
|
|
(new DefaultBtProgressInfoFile(downloadContext_,
|
|
|
|
pieceStorage_,
|
|
|
|
option_.get()));
|
2010-02-26 15:37:08 +00:00
|
|
|
removeDefunctControlFile(progressInfoFile);
|
|
|
|
// Call Load, Save and file allocation command here
|
|
|
|
if(progressInfoFile->exists()) {
|
|
|
|
// load .aria2 file if it exists.
|
|
|
|
progressInfoFile->load();
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openFile();
|
2009-05-07 03:49:27 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(pieceStorage_->getDiskAdaptor()->fileExists()) {
|
2010-09-15 11:46:25 +00:00
|
|
|
if(!isCheckIntegrityReady() &&
|
2010-06-21 13:51:56 +00:00
|
|
|
!option_->getAsBool(PREF_ALLOW_OVERWRITE)) {
|
2010-02-26 15:37:08 +00:00
|
|
|
// TODO we need this->haltRequested = true?
|
2010-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt(MSG_FILE_ALREADY_EXISTS,
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()),
|
2010-11-28 08:29:32 +00:00
|
|
|
error_code::FILE_ALREADY_EXISTS);
|
2010-02-26 15:37:08 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openFile();
|
2010-02-26 15:37:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openFile();
|
2010-02-26 15:37:08 +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
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
progressInfoFile_ = progressInfoFile;
|
2010-02-26 15:37:08 +00:00
|
|
|
SharedHandle<CheckIntegrityEntry> checkIntegrityEntry
|
|
|
|
(new StreamCheckIntegrityEntry(this));
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
void RequestGroup::processCheckIntegrityEntry
|
|
|
|
(std::vector<Command*>& commands,
|
|
|
|
const SharedHandle<CheckIntegrityEntry>& 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
|
|
|
{
|
2010-09-10 11:52:16 +00:00
|
|
|
uint64_t actualFileSize = pieceStorage_->getDiskAdaptor()->size();
|
|
|
|
if(actualFileSize > downloadContext_->getTotalLength()) {
|
|
|
|
entry->cutTrailingGarbage();
|
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2010-09-10 11:52:16 +00:00
|
|
|
if((option_->getAsBool(PREF_CHECK_INTEGRITY) ||
|
|
|
|
downloadContext_->isChecksumVerificationNeeded()) &&
|
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-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();
|
2010-06-08 14:11:36 +00:00
|
|
|
e->getCheckIntegrityMan()->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()
|
|
|
|
{
|
2010-01-29 11:03:14 +00:00
|
|
|
SharedHandle<PieceStorage> tempPieceStorage;
|
2010-09-06 14:29:36 +00:00
|
|
|
if(downloadContext_->knowsTotalLength() &&
|
2010-09-13 11:53:38 +00:00
|
|
|
// Following conditions are needed for chunked encoding with
|
|
|
|
// content-length = 0. Google's dl server used this before.
|
2010-09-11 15:54:53 +00:00
|
|
|
(downloadContext_->getTotalLength() > 0
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
|| downloadContext_->hasAttribute(bittorrent::BITTORRENT)
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
)) {
|
2009-01-31 14:34:29 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-11-15 12:02:54 +00:00
|
|
|
DefaultPieceStorage* ps =
|
|
|
|
new DefaultPieceStorage(downloadContext_, option_.get());
|
|
|
|
SharedHandle<PieceStorage> psHolder(ps);
|
2010-06-21 13:51:56 +00:00
|
|
|
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
|
2009-11-29 06:43:38 +00:00
|
|
|
if(isUriSuppliedForRequsetFileEntry
|
2010-06-21 13:51:56 +00:00
|
|
|
(downloadContext_->getFileEntries().begin(),
|
|
|
|
downloadContext_->getFileEntries().end())) {
|
2010-01-05 16:01:46 +00:00
|
|
|
// Use LongestSequencePieceSelector when HTTP/FTP/BitTorrent
|
|
|
|
// integrated downloads. Currently multi-file integrated
|
|
|
|
// download is not supported.
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG("Using LongestSequencePieceSelector");
|
2010-11-11 05:12:37 +00:00
|
|
|
SharedHandle<PieceSelector> longestPieceSelector
|
|
|
|
(new LongestSequencePieceSelector());
|
|
|
|
ps->setPieceSelector(longestPieceSelector);
|
2009-11-29 06:43:38 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->defined(PREF_BT_PRIORITIZE_PIECE)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
std::vector<size_t> result;
|
|
|
|
util::parsePrioritizePieceRange
|
2010-06-21 13:51:56 +00:00
|
|
|
(result, option_->get(PREF_BT_PRIORITIZE_PIECE),
|
|
|
|
downloadContext_->getFileEntries(),
|
|
|
|
downloadContext_->getPieceLength());
|
2010-01-05 16:01:46 +00:00
|
|
|
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
|
2010-11-15 12:02:54 +00:00
|
|
|
DefaultPieceStorage* ps =
|
|
|
|
new DefaultPieceStorage(downloadContext_, option_.get());
|
|
|
|
SharedHandle<PieceStorage> psHolder(ps);
|
2009-01-31 14:34:29 +00:00
|
|
|
#endif // !ENABLE_BITTORRENT
|
2010-11-12 12:48:48 +00:00
|
|
|
if(diskWriterFactory_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
ps->setDiskWriterFactory(diskWriterFactory_);
|
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
|
|
|
}
|
2010-11-15 12:02:54 +00:00
|
|
|
tempPieceStorage.swap(psHolder);
|
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-11-15 12:02:54 +00:00
|
|
|
UnknownLengthPieceStorage* ps =
|
|
|
|
new UnknownLengthPieceStorage(downloadContext_, option_.get());
|
|
|
|
SharedHandle<PieceStorage> psHolder(ps);
|
2010-11-12 12:48:48 +00:00
|
|
|
if(diskWriterFactory_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
ps->setDiskWriterFactory(diskWriterFactory_);
|
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
|
|
|
}
|
2010-11-15 12:02:54 +00:00
|
|
|
tempPieceStorage.swap(psHolder);
|
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
|
|
|
}
|
2010-01-29 11:03:14 +00:00
|
|
|
tempPieceStorage->initStorage();
|
2010-02-11 11:42:20 +00:00
|
|
|
SharedHandle<SegmentMan> tempSegmentMan
|
2010-06-21 13:51:56 +00:00
|
|
|
(new SegmentMan(option_.get(), downloadContext_, tempPieceStorage));
|
2010-01-29 11:03:14 +00:00
|
|
|
|
2010-11-15 12:02:54 +00:00
|
|
|
pieceStorage_.swap(tempPieceStorage);
|
|
|
|
segmentMan_.swap(tempSegmentMan);
|
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
|
|
|
}
|
|
|
|
|
2010-04-13 12:39:09 +00:00
|
|
|
void RequestGroup::dropPieceStorage()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
segmentMan_.reset();
|
|
|
|
pieceStorage_.reset();
|
2010-04-13 12:39:09 +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
|
|
|
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() ||
|
2010-09-15 11:46:25 +00:00
|
|
|
option_->getAsBool(PREF_ALLOW_OVERWRITE)) {
|
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;
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!downloadContext_->knowsTotalLength()) {
|
2009-05-07 03:49:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
2009-06-28 10:37:15 +00:00
|
|
|
File outfile(getFirstFilePath());
|
2010-06-21 13:51:56 +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.
|
2010-03-25 14:44:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
if(!option_->getAsBool(PREF_DRY_RUN) &&
|
|
|
|
option_->getAsBool(PREF_REMOVE_CONTROL_FILE) &&
|
2010-03-25 14:44:16 +00:00
|
|
|
infoFile->exists()) {
|
|
|
|
infoFile->removeFile();
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_NOTICE(fmt("Removed control file for %s because it is requested by"
|
|
|
|
" user.",
|
|
|
|
infoFile->getFilename().c_str()));
|
2010-03-25 14:44:16 +00:00
|
|
|
}
|
|
|
|
if(infoFile->exists()) {
|
2009-05-07 03:49:27 +00:00
|
|
|
// 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());
|
2010-06-21 13:51:56 +00:00
|
|
|
if(outfile.exists() && option_->getAsBool(PREF_CONTINUE) &&
|
|
|
|
outfile.size() <= downloadContext_->getTotalLength()) {
|
2009-05-07 03:49:27 +00:00
|
|
|
// File exists but user decided to resume it.
|
|
|
|
} else {
|
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2010-09-15 11:46:25 +00:00
|
|
|
if(outfile.exists() && isCheckIntegrityReady()) {
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-26 15:37:08 +00:00
|
|
|
void RequestGroup::removeDefunctControlFile
|
|
|
|
(const SharedHandle<BtProgressInfoFile>& progressInfoFile)
|
|
|
|
{
|
|
|
|
// Remove the control file if download file doesn't exist
|
|
|
|
if(progressInfoFile->exists() &&
|
2010-06-21 13:51:56 +00:00
|
|
|
!pieceStorage_->getDiskAdaptor()->fileExists()) {
|
2010-02-26 15:37:08 +00:00
|
|
|
progressInfoFile->removeFile();
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_NOTICE(fmt(MSG_REMOVED_DEFUNCT_CONTROL_FILE,
|
|
|
|
progressInfoFile->getFilename().c_str(),
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
2010-02-26 15:37:08 +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
|
|
|
void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoFile)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
if(!isPreLocalFileCheckEnabled()) {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->initAndOpenFile();
|
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;
|
|
|
|
}
|
2010-02-26 15:37:08 +00:00
|
|
|
removeDefunctControlFile(progressInfoFile);
|
2009-05-07 03:49:27 +00:00
|
|
|
if(progressInfoFile->exists()) {
|
|
|
|
progressInfoFile->load();
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openExistingFile();
|
2009-05-07 03:49:27 +00:00
|
|
|
} else {
|
2009-06-28 10:37:15 +00:00
|
|
|
File outfile(getFirstFilePath());
|
2010-06-21 13:51:56 +00:00
|
|
|
if(outfile.exists() && option_->getAsBool(PREF_CONTINUE) &&
|
2010-01-05 16:01:46 +00:00
|
|
|
outfile.size() <= getTotalLength()) {
|
2010-06-21 13:51:56 +00:00
|
|
|
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-09-15 11:46:25 +00:00
|
|
|
if(outfile.exists() && isCheckIntegrityReady()) {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->openExistingFile();
|
2010-01-05 16:01:46 +00:00
|
|
|
} else {
|
2008-05-05 10:10:15 +00:00
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
2010-06-21 13:51:56 +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) {
|
2010-11-20 09:36:14 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2(fmt(EX_DOWNLOAD_ABORTED), 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()
|
|
|
|
{
|
2010-06-21 13:51:56 +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()) {
|
2010-06-21 13:51:56 +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()) {
|
2011-08-04 12:43:02 +00:00
|
|
|
A2_LOG_NOTICE(fmt(MSG_FILE_RENAMED,
|
|
|
|
utf8ToNative(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-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt("File renaming failed: %s",
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(getFirstFilePath()).c_str()),
|
2010-11-28 08:29:32 +00:00
|
|
|
error_code::FILE_RENAMING_FAILED);
|
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 {
|
2010-11-28 08:29:32 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt(MSG_FILE_ALREADY_EXISTS,
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(getFirstFilePath()).c_str()),
|
2010-11-28 08:29:32 +00:00
|
|
|
error_code::FILE_ALREADY_EXISTS);
|
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())) {
|
2010-06-21 13:51:56 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
void RequestGroup::createNextCommandWithAdj(std::vector<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 {
|
2010-06-21 13:51:56 +00:00
|
|
|
numCommand = std::min(downloadContext_->getNumPieces(),
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-03-07 03:10:19 +00:00
|
|
|
void RequestGroup::createNextCommand(std::vector<Command*>& commands,
|
|
|
|
DownloadEngine* e)
|
|
|
|
{
|
|
|
|
int numCommand;
|
|
|
|
if(getTotalLength() == 0) {
|
2010-07-17 03:23:56 +00:00
|
|
|
if(numStreamCommand_ > 0) {
|
2010-03-07 03:10:19 +00:00
|
|
|
numCommand = 0;
|
|
|
|
} else {
|
|
|
|
numCommand = 1;
|
|
|
|
}
|
|
|
|
} else {
|
2010-07-17 03:23:56 +00:00
|
|
|
if(numStreamCommand_ >= numConcurrentCommand_) {
|
2010-03-07 03:10:19 +00:00
|
|
|
numCommand = 0;
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
numCommand = std::min(downloadContext_->getNumPieces(),
|
2010-07-17 03:23:56 +00:00
|
|
|
numConcurrentCommand_-numStreamCommand_);
|
2010-03-07 03:10:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(numCommand > 0) {
|
|
|
|
createNextCommand(commands, e, numCommand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
void RequestGroup::createNextCommand(std::vector<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
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
assert(downloadContext_);
|
2008-11-14 12:32:54 +00:00
|
|
|
if(inMemoryDownload()) {
|
|
|
|
static const std::string DIR_MEMORY("[MEMORY]");
|
2010-06-21 13:51:56 +00:00
|
|
|
return DIR_MEMORY+File(downloadContext_->getFirstFileEntry()->getPath()).getBasename();
|
2007-07-01 10:40:30 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +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
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!pieceStorage_) {
|
2007-10-11 16:58:24 +00:00
|
|
|
return 0;
|
2007-05-20 13:57:56 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(pieceStorage_->isSelectiveDownloadingMode()) {
|
|
|
|
return pieceStorage_->getFilteredTotalLength();
|
2007-05-20 13:57:56 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +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
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!pieceStorage_) {
|
2007-10-11 16:58:24 +00:00
|
|
|
return 0;
|
2007-05-20 13:57:56 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(pieceStorage_->isSelectiveDownloadingMode()) {
|
|
|
|
return pieceStorage_->getFilteredCompletedLength();
|
2007-05-31 15:56:20 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +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) {
|
2010-11-20 09:36:14 +00:00
|
|
|
throw DL_ABORT_EX(fmt(EX_FILENAME_MISMATCH,
|
|
|
|
expectedFilename.c_str(),
|
|
|
|
actualFilename.c_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
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt(EX_SIZE_MISMATCH,
|
|
|
|
util::itos(expectedTotalLength, true).c_str(),
|
|
|
|
util::itos(actualTotalLength, true).c_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
|
|
|
{
|
2010-06-21 13:51:56 +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
|
|
|
}
|
|
|
|
|
2010-07-17 03:23:56 +00:00
|
|
|
void RequestGroup::increaseStreamCommand()
|
|
|
|
{
|
|
|
|
++numStreamCommand_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::decreaseStreamCommand()
|
|
|
|
{
|
|
|
|
--numStreamCommand_;
|
|
|
|
}
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
void RequestGroup::increaseStreamConnection()
|
2007-06-04 12:52:57 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +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
|
|
|
{
|
2010-06-21 13:51:56 +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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
unsigned int numConnection = numStreamConnection_;
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-11-12 12:48:48 +00:00
|
|
|
if(btRuntime_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
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()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
++numCommand_;
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::decreaseNumCommand()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
--numCommand_;
|
|
|
|
if(!numCommand_ && requestGroupMan_) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt("GID#%s - Request queue check", util::itos(gid_).c_str()));
|
2010-06-21 13:51:56 +00:00
|
|
|
requestGroupMan_->requestQueueCheck();
|
2010-03-05 14:02:23 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
TransferStat RequestGroup::calculateStat() const
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
|
|
|
TransferStat stat;
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-11-12 12:48:48 +00:00
|
|
|
if(peerStorage_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
stat = peerStorage_->calculateStat();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
2010-11-12 12:48:48 +00:00
|
|
|
if(segmentMan_) {
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
stat.setDownloadSpeed
|
2010-06-21 13:51:56 +00:00
|
|
|
(stat.getDownloadSpeed()+segmentMan_->calculateDownloadSpeed());
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
stat.setSessionDownloadLength
|
|
|
|
(stat.getSessionDownloadLength()+
|
2010-06-21 13:51:56 +00:00
|
|
|
segmentMan_->calculateSessionDownloadLength());
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
haltRequested_ = f;
|
|
|
|
if(haltRequested_) {
|
|
|
|
pauseRequested_ = false;
|
|
|
|
haltReason_ = haltReason;
|
2009-05-09 04:11:31 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-11-12 12:48:48 +00:00
|
|
|
if(btRuntime_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
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);
|
2010-06-21 13:51:56 +00:00
|
|
|
forceHaltRequested_ = f;
|
2007-12-07 13:33:59 +00:00
|
|
|
}
|
|
|
|
|
2010-04-08 16:02:22 +00:00
|
|
|
void RequestGroup::setPauseRequested(bool f)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
pauseRequested_ = f;
|
2010-04-08 16:02:22 +00:00
|
|
|
}
|
|
|
|
|
2008-11-03 06:49:02 +00:00
|
|
|
void RequestGroup::releaseRuntimeResource(DownloadEngine* e)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-06-21 13:51:56 +00:00
|
|
|
e->getBtRegistry()->remove(gid_);
|
2011-07-21 14:59:44 +00:00
|
|
|
btRuntime_ = 0;
|
|
|
|
peerStorage_ = 0;
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
2010-11-12 12:48:48 +00:00
|
|
|
if(pieceStorage_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->removeAdvertisedPiece(0);
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
// Don't reset segmentMan_ and pieceStorage_ here to provide
|
2011-03-18 13:45:25 +00:00
|
|
|
// progress information via RPC
|
2010-06-21 13:51:56 +00:00
|
|
|
progressInfoFile_.reset();
|
|
|
|
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()
|
|
|
|
{
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt("Finding PreDownloadHandler for path %s.",
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(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 {
|
2010-02-28 12:30:11 +00:00
|
|
|
for(std::vector<SharedHandle<PreDownloadHandler> >::const_iterator itr =
|
2010-06-21 13:51:56 +00:00
|
|
|
preDownloadHandlers_.begin(), eoi = preDownloadHandlers_.end();
|
2010-02-28 16:04:52 +00:00
|
|
|
itr != eoi; ++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) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, 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
|
|
|
return;
|
|
|
|
}
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG("No PreDownloadHandler found.");
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-11 13:59:27 +00:00
|
|
|
void RequestGroup::postDownloadProcessing
|
2010-02-28 12:30:11 +00:00
|
|
|
(std::vector<SharedHandle<RequestGroup> >& groups)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt("Finding PostDownloadHandler for path %s.",
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(getFirstFilePath()).c_str()));
|
2007-10-15 14:55:24 +00:00
|
|
|
try {
|
2010-02-28 12:30:11 +00:00
|
|
|
for(std::vector<SharedHandle<PostDownloadHandler> >::const_iterator itr =
|
2010-06-21 13:51:56 +00:00
|
|
|
postDownloadHandlers_.begin(), eoi = postDownloadHandlers_.end();
|
2010-02-28 16:04:52 +00:00
|
|
|
itr != eoi; ++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) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_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
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->get(PREF_FOLLOW_TORRENT) == V_MEM) {
|
|
|
|
preDownloadHandlers_.push_back(DownloadHandlerFactory::getBtPreDownloadHandler());
|
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
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->get(PREF_FOLLOW_METALINK) == V_MEM) {
|
|
|
|
preDownloadHandlers_.push_back(DownloadHandlerFactory::getMetalinkPreDownloadHandler());
|
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
|
|
|
}
|
|
|
|
#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
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->getAsBool(PREF_FOLLOW_TORRENT) ||
|
|
|
|
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
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option_->getAsBool(PREF_FOLLOW_METALINK) ||
|
|
|
|
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()
|
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(!dependency_) {
|
2007-10-11 16:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
return dependency_->resolve();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::dependsOn(const DependencyHandle& dep)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
dependency_ = dep;
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::setDiskWriterFactory(const DiskWriterFactoryHandle& diskWriterFactory)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
diskWriterFactory_ = diskWriterFactory;
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
void RequestGroup::addPostDownloadHandler
|
|
|
|
(const SharedHandle<PostDownloadHandler>& handler)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
postDownloadHandlers_.push_back(handler);
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
void RequestGroup::addPreDownloadHandler
|
|
|
|
(const SharedHandle<PreDownloadHandler>& 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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
preDownloadHandlers_.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
|
|
|
}
|
|
|
|
|
2009-11-23 13:17:48 +00:00
|
|
|
void RequestGroup::clearPostDownloadHandler()
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
postDownloadHandlers_.clear();
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
preDownloadHandlers_.clear();
|
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-10-11 16:58:24 +00:00
|
|
|
void RequestGroup::setPieceStorage(const PieceStorageHandle& pieceStorage)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_ = pieceStorage;
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::setProgressInfoFile(const BtProgressInfoFileHandle& progressInfoFile)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
progressInfoFile_ = progressInfoFile;
|
2007-08-28 15:46:49 +00:00
|
|
|
}
|
2007-10-29 12:43:45 +00:00
|
|
|
|
|
|
|
bool RequestGroup::needsFileAllocation() const
|
|
|
|
{
|
|
|
|
return isFileAllocationEnabled() &&
|
2010-06-21 13:51:56 +00:00
|
|
|
(uint64_t)option_->getAsLLInt(PREF_NO_FILE_ALLOCATION_LIMIT) <= getTotalLength() &&
|
|
|
|
!pieceStorage_->getDiskAdaptor()->fileAllocationIterator()->finished();
|
2007-10-29 12:43:45 +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
|
|
|
|
|
|
|
DownloadResultHandle RequestGroup::createDownloadResult() const
|
|
|
|
{
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt("GID#%s - Creating DownloadResult.",
|
|
|
|
util::itos(gid_).c_str()));
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
TransferStat st = calculateStat();
|
2010-05-20 12:16:50 +00:00
|
|
|
SharedHandle<DownloadResult> res(new DownloadResult());
|
2010-06-21 13:51:56 +00:00
|
|
|
res->gid = gid_;
|
|
|
|
res->fileEntries = downloadContext_->getFileEntries();
|
|
|
|
res->inMemoryDownload = inMemoryDownload_;
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
res->sessionDownloadLength = st.getSessionDownloadLength();
|
2010-06-21 13:51:56 +00:00
|
|
|
res->sessionTime = downloadContext_->calculateSessionTime();
|
2010-05-20 12:16:50 +00:00
|
|
|
res->result = downloadResult();
|
2010-06-21 13:51:56 +00:00
|
|
|
res->followedBy = followedByGIDs_;
|
|
|
|
res->belongsTo = belongsToGID_;
|
|
|
|
res->option = option_;
|
|
|
|
res->metadataInfo = metadataInfo_;
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
res->totalLength = getTotalLength();
|
|
|
|
res->completedLength = getCompletedLength();
|
|
|
|
res->uploadLength = st.getAllTimeUploadLength();
|
2010-11-12 12:48:48 +00:00
|
|
|
if(pieceStorage_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(pieceStorage_->getBitfieldLength() > 0) {
|
|
|
|
res->bitfieldStr = util::toHex(pieceStorage_->getBitfield(),
|
|
|
|
pieceStorage_->getBitfieldLength());
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-06-21 13:51:56 +00:00
|
|
|
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
|
|
|
|
res->infoHashStr = bittorrent::getInfoHashString(downloadContext_);
|
2010-05-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added totalLength, completedLength, uploadLength, bitfield,
downloadSpeed, uploadSpeed, infoHash, numSeeders, pieceLength,
numPieces, connections and dir to the response of
aria2.tellStopped XML-RPC method. aria2.tellWaiting now always
returns numSeeders for BitTorrent download.
* src/DownloadResult.h
* src/RequestGroup.cc
* src/RequestGroup.h
* src/XmlRpcMethodImpl.cc
* test/XmlRpcMethodTest.cc
2010-05-22 11:50:47 +00:00
|
|
|
}
|
|
|
|
#endif // ENABLE_BITTORRENT
|
2010-06-21 13:51:56 +00:00
|
|
|
res->pieceLength = downloadContext_->getPieceLength();
|
|
|
|
res->numPieces = downloadContext_->getNumPieces();
|
2010-12-03 04:08:22 +00:00
|
|
|
res->dir = option_->get(PREF_DIR);
|
2010-05-20 12:16:50 +00:00
|
|
|
return res;
|
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()
|
|
|
|
{
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_NOTICE(fmt(MSG_FILE_DOWNLOAD_COMPLETED,
|
2011-08-04 12:43:02 +00:00
|
|
|
utf8ToNative(downloadContext_->getBasePath()).c_str()));
|
2010-06-21 13:51:56 +00:00
|
|
|
uriSelector_->resetCounters();
|
2007-12-29 07:02:35 +00:00
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-06-21 13:51:56 +00:00
|
|
|
if(downloadContext_->hasAttribute(bittorrent::BITTORRENT)) {
|
2008-09-19 14:15:06 +00:00
|
|
|
TransferStat stat = calculateStat();
|
2010-12-04 11:56:52 +00:00
|
|
|
uint64_t completedLength = getCompletedLength();
|
|
|
|
double shareRatio = completedLength == 0 ? 0.0 :
|
|
|
|
1.0*stat.getAllTimeUploadLength()/completedLength;
|
2010-06-18 14:47:09 +00:00
|
|
|
SharedHandle<TorrentAttribute> attrs =
|
2010-06-21 13:51:56 +00:00
|
|
|
bittorrent::getTorrentAttrs(downloadContext_);
|
2010-06-18 14:47:09 +00:00
|
|
|
if(!attrs->metadata.empty()) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_NOTICE(fmt(MSG_SHARE_RATIO_REPORT,
|
|
|
|
shareRatio,
|
|
|
|
util::abbrevSize(stat.getAllTimeUploadLength()).c_str(),
|
2010-12-04 11:56:52 +00:00
|
|
|
util::abbrevSize(completedLength).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)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(std::find(acceptTypes_.begin(), acceptTypes_.end(), type) == acceptTypes_.end()) {
|
|
|
|
acceptTypes_.push_back(type);
|
2008-05-05 08:25:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::removeAcceptType(const std::string& type)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
acceptTypes_.erase(std::remove(acceptTypes_.begin(), acceptTypes_.end(), type),
|
|
|
|
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)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
uriSelector_ = uriSelector;
|
2008-08-04 17:06:47 +00:00
|
|
|
}
|
|
|
|
|
2008-09-07 14:38:26 +00:00
|
|
|
void RequestGroup::applyLastModifiedTimeToLocalFiles()
|
|
|
|
{
|
2010-11-12 12:48:48 +00:00
|
|
|
if(pieceStorage_ && lastModifiedTime_.good()) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_INFO(fmt("Applying Last-Modified time: %s",
|
|
|
|
lastModifiedTime_.toHTTPDate().c_str()));
|
2008-09-07 14:38:26 +00:00
|
|
|
size_t n =
|
2010-06-21 13:51:56 +00:00
|
|
|
pieceStorage_->getDiskAdaptor()->utime(Time(), lastModifiedTime_);
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_INFO(fmt("Last-Modified attrs of %lu files were updated.",
|
|
|
|
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)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(time.good() && lastModifiedTime_ < time) {
|
|
|
|
lastModifiedTime_ = time;
|
2008-09-07 14:38:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-10 14:56:44 +00:00
|
|
|
void RequestGroup::increaseAndValidateFileNotFoundCount()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
++fileNotFoundCount_;
|
|
|
|
const unsigned int maxCount = option_->getAsInt(PREF_MAX_FILE_NOT_FOUND);
|
|
|
|
if(maxCount > 0 && fileNotFoundCount_ >= maxCount &&
|
2010-11-12 12:48:48 +00:00
|
|
|
(!segmentMan_ ||
|
2010-06-21 13:51:56 +00:00
|
|
|
segmentMan_->calculateSessionDownloadLength() == 0)) {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
2010-11-20 09:36:14 +00:00
|
|
|
(fmt("Reached max-file-not-found count=%u", maxCount),
|
2010-11-28 07:52:02 +00:00
|
|
|
error_code::MAX_FILE_NOT_FOUND);
|
2008-09-10 14:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-14 12:02:16 +00:00
|
|
|
void RequestGroup::markInMemoryDownload()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
inMemoryDownload_ = true;
|
2008-11-14 12:02:16 +00:00
|
|
|
}
|
|
|
|
|
2009-02-01 02:55:44 +00:00
|
|
|
void RequestGroup::setTimeout(time_t timeout)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
timeout_ = timeout;
|
2009-02-01 02:55:44 +00:00
|
|
|
}
|
|
|
|
|
2009-02-28 11:48:26 +00:00
|
|
|
bool RequestGroup::doesDownloadSpeedExceed()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return maxDownloadSpeedLimit_ > 0 &&
|
|
|
|
maxDownloadSpeedLimit_ < calculateStat().getDownloadSpeed();
|
2009-02-28 11:48:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RequestGroup::doesUploadSpeedExceed()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return maxUploadSpeedLimit_ > 0 &&
|
|
|
|
maxUploadSpeedLimit_ < calculateStat().getUploadSpeed();
|
2009-02-28 11:48:26 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 13:35:09 +00:00
|
|
|
void RequestGroup::saveControlFile() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(saveControlFile_) {
|
|
|
|
progressInfoFile_->save();
|
2009-10-05 13:35:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RequestGroup::removeControlFile() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
progressInfoFile_->removeFile();
|
2009-10-05 13:35:09 +00:00
|
|
|
}
|
|
|
|
|
2009-11-28 10:12:04 +00:00
|
|
|
void RequestGroup::setDownloadContext
|
|
|
|
(const SharedHandle<DownloadContext>& downloadContext)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_ = downloadContext;
|
2010-11-12 12:48:48 +00:00
|
|
|
if(downloadContext_) {
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_->setOwnerRequestGroup(this);
|
2009-11-28 10:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-28 07:23:33 +00:00
|
|
|
bool RequestGroup::p2pInvolved() const
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2010-06-21 13:51:56 +00:00
|
|
|
return downloadContext_->hasAttribute(bittorrent::BITTORRENT);
|
2010-03-28 07:23:33 +00:00
|
|
|
#else // !ENABLE_BITTORRENT
|
|
|
|
return false;
|
|
|
|
#endif // !ENABLE_BITTORRENT
|
|
|
|
}
|
|
|
|
|
2011-03-17 03:17:46 +00:00
|
|
|
a2_gid_t RequestGroup::newGID()
|
2010-01-10 07:51:45 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(gidCounter_ == INT64_MAX) {
|
|
|
|
gidCounter_ = 0;
|
2010-01-10 07:51:45 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
return ++gidCounter_;
|
2010-01-10 07:51:45 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|