aria2/src/FileEntry.cc

448 lines
13 KiB
C++
Raw Normal View History

2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> To divide TorrentMan into 6 classes: BtContext, BtRuntime, PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile * src/TrackerWatcherComand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.cc: Use pieceStorage, btRuntime * src/PeerAbstractCommand.h: Made subclass of BtContextAwareCommand. * src/PeerAbstractCommand.cc: Use btRuntime. * src/BtContextAwareCommand.h: New class. * src/FileEntry.h: Added accessor methods for following variables. (path): Made private. (length): Made private. (offset): Made private. (extracted): Made private. (requested): Made private. (FileEntries): New definition. (FileEntryHandle): New definition. * src/FileEntry.cc: New file. * src/HaveEraseCommand.h: Made subclass of BtContextAwareCommand. * src/HaveEraseCommand.cc: Use btRuntime, pieceStorage. * src/PeerChokeCommand.h: Made subclass of BtContextAwareCommand. * src/PeerChokeCommand.cc: Use btRuntime, peerStorage, pieceStorage. * src/PieceStorage.h: New file. * src/PeerInteractionCommand.h: Use btContext. * src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage, btRuntime. * src/DefaultBtProgressInfoFile.h: New file. * src/DefaultBtProgressInfoFile.cc: New file. * src/File.cc (Util.h): New include. (mkdirs): New function. * src/MultiDiskAdaptor.h (mkdir): New function. * src/PeerListProcessor.h (Peers): Removed. * src/PeerInteraction.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (btAnnounce): New variable. (getTorrentMan): Removed. (getBtContext): New function. * src/PeerInteraction.cc: Use btContext, peerStorage, pieceStorage, btAnnounce. * src/HandshakeMessage.h (TorrentMan.h): Removed. * src/HandshakeMessage.cc: Use btContext. * src/DefaultBtAnnounce.cc: New file. * src/MultiDiskWriter.cc: Use the accessor methods of FileEntry. * src/DefaultPieceStorage.cc: New file. * src/DefaultBtContext.h: New file. * src/TorrentRequestInfo.cc: Use btContext, pieceStorage. Use the accessor methods of FileEntry. * src/CookieBox.cc: Updated to use Util::slice(). * src/PieceMessage.cc: Use btContext, pieceStorage. * src/common.h (SharedHandle.h): New include. * src/PeerMessage.cc (PeerMessage): Added btContext, peerStorage, pieceStorage. * src/TorrentAutoSaveCommand.h: Made subclass of BtContextAwareCommand. * src/DiskAdaptor.h (topDir): Removed. (getFileEntryFromPath): Changed the return type to FileEntryHandle. (setTopDir): Removed. (getTopDir): Removed. * src/BtContext.h: New file. * src/DefaultPeerStorage.h: New file. * src/PieceMessage.h (TorrentMan.h): Removed. * src/RequestMessage.h (TorrentMan.h): Removed. * src/TorrentDownloadEngine.h (uploadLength): New variable. (btContext): New variable. (btRuntime): New variable. (pieceStorage): New variable. (peerStorage): New variable. (btAnnounce): New variable. (btProgressInfoFile): New variable. (torrentMan): Removed. (setBtContext): New function. * src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, pieceStorage, peerStorage, btAnnounce, btProgressInfoFile. * src/Piece.h (toString): New function. (Pieces): New type definition. * src/Peer.h (active): New variable. (Peer): Added active. (activate): Set active to true. (deactivate): Set active to false. (isActive): New function. (Peers): New type definition. * src/DirectDiskAdaptor.cc (getFilePath): Use the accessor methods of FileEntry. * src/TorrentConsoleDownloadEngine.h (afterEachIteration): New function. * src/TorrentConsoleDownloadEngine.cc (haltRequested): New variable. (sendStatistics): Use pieceStorage, btRuntime. (afterEachIteration): New function. * src/AnnounceList: AnnounceTier->AnnounceTierHandle. * src/Directry.h (Directory): New function. (DirectoryHandle): New type definition. * src/BtProgressInfoFile.h: New file. * src/RequestMessage.cc: Use pieceStorage. * src/BtRuntime.h: New file. * src/DefaultBtContext.cc: New file. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/MultiDiskAdaptor.cc (mkdir): New function. (openFile): Call mkdir(). (initAndOpenFile): Call mkdir(). * src/CancelMessage.h (TorrentMan.h): Removed. * src/RejectMessage.h (TorrentMan.h): Removed. * src/DownloadEngineFactory.cc (DefaultPieceStorage.h): New include. (DefaultPeerStorage.h): New include. (DefaultBtAnnounce.h): New include. (DefaultBtProgressInfoFile.h): New include. (newTorrentConsoleEngine): Rewritten. * src/ShareRatioSeedCriteria.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (btRuntime): New variable. (evaluate): Use btContext, btRuntime, peerStorage. * src/AnnounceTier.h: New file. * src/BtAnnounce.h: New file. * src/BtRegistry.h: New file. * src/PeerInitiateConnectionCommand.h: Added btContext. * src/PeerConnection.h (TorrentMan.h): Removed. * src/PeerMessageFactory.cc: Use btContext, pieceStorage. * src/Util.h (slice): Added an argument. * src/Util.cc (slice): Added an argument to control whether trim is made or not. * src/PeerStorage.h: New file. * src/BtRegistry.cc: New file. * src/TrackerUpdateCommand.h: Made subclass of BtContextAwareCommand. * src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry. * src/MultiDiskWriter.h: FileEntry -> FileEntryHandle * src/PeerListenCommand.cc: Use btRuntime, peerStorage, btContext. * src/TorrentRequestInfo.h (e): Removed. (showFileEntry): Added an argument. (getDownloadEngine): Return 0. * src/DefaultBtAnnounce.h: New file. * src/TorrentAutoSaveCommand.cc: Use btRuntime, btProgressInfoFile. * src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce, * src/PeerMessageFactory.h (btContext): New variable. (pieceStorage): New variable. * src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, btContext, btAnnounce. * src/DiskAdaptor.cc (DiskAdaptor): Removed topDir. (~DiskAdaptor): Removed topDir. * src/PeerListenCommand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.h: Made subclass of BtContextAwareCommand. * src/File.h (mkdirs): New function. * src/DefaultPeerStorage): New file. * src/DownloadEngineFactory.h (newTorrentConsoleEngine): Use btContext. * src/BtContextAwareCommand.cc: New file. * src/PeerInitiateConnectionCommand.cc: Use btRuntime, peerStorage. * src/PeerMessage.h (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (setBtContext): New function. * src/Directry.cc (Directory): New function. (createDir): Do nothing if name.size() == 0. * src/AnnounceList.h (AnnounceTier): Removed. (AnnounceTiers): Removed. * src/DefaultPieceStorage.h: New file. * src/Piece.cc (toString): New function. To fix typo: * src/main.cc (showVersion): Fixed typo. To fix compile warning: * src/DelegatingPeerListProcessor.cc (canHandle): Added "return false".
2006-11-05 15:04:17 +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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> To divide TorrentMan into 6 classes: BtContext, BtRuntime, PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile * src/TrackerWatcherComand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.cc: Use pieceStorage, btRuntime * src/PeerAbstractCommand.h: Made subclass of BtContextAwareCommand. * src/PeerAbstractCommand.cc: Use btRuntime. * src/BtContextAwareCommand.h: New class. * src/FileEntry.h: Added accessor methods for following variables. (path): Made private. (length): Made private. (offset): Made private. (extracted): Made private. (requested): Made private. (FileEntries): New definition. (FileEntryHandle): New definition. * src/FileEntry.cc: New file. * src/HaveEraseCommand.h: Made subclass of BtContextAwareCommand. * src/HaveEraseCommand.cc: Use btRuntime, pieceStorage. * src/PeerChokeCommand.h: Made subclass of BtContextAwareCommand. * src/PeerChokeCommand.cc: Use btRuntime, peerStorage, pieceStorage. * src/PieceStorage.h: New file. * src/PeerInteractionCommand.h: Use btContext. * src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage, btRuntime. * src/DefaultBtProgressInfoFile.h: New file. * src/DefaultBtProgressInfoFile.cc: New file. * src/File.cc (Util.h): New include. (mkdirs): New function. * src/MultiDiskAdaptor.h (mkdir): New function. * src/PeerListProcessor.h (Peers): Removed. * src/PeerInteraction.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (btAnnounce): New variable. (getTorrentMan): Removed. (getBtContext): New function. * src/PeerInteraction.cc: Use btContext, peerStorage, pieceStorage, btAnnounce. * src/HandshakeMessage.h (TorrentMan.h): Removed. * src/HandshakeMessage.cc: Use btContext. * src/DefaultBtAnnounce.cc: New file. * src/MultiDiskWriter.cc: Use the accessor methods of FileEntry. * src/DefaultPieceStorage.cc: New file. * src/DefaultBtContext.h: New file. * src/TorrentRequestInfo.cc: Use btContext, pieceStorage. Use the accessor methods of FileEntry. * src/CookieBox.cc: Updated to use Util::slice(). * src/PieceMessage.cc: Use btContext, pieceStorage. * src/common.h (SharedHandle.h): New include. * src/PeerMessage.cc (PeerMessage): Added btContext, peerStorage, pieceStorage. * src/TorrentAutoSaveCommand.h: Made subclass of BtContextAwareCommand. * src/DiskAdaptor.h (topDir): Removed. (getFileEntryFromPath): Changed the return type to FileEntryHandle. (setTopDir): Removed. (getTopDir): Removed. * src/BtContext.h: New file. * src/DefaultPeerStorage.h: New file. * src/PieceMessage.h (TorrentMan.h): Removed. * src/RequestMessage.h (TorrentMan.h): Removed. * src/TorrentDownloadEngine.h (uploadLength): New variable. (btContext): New variable. (btRuntime): New variable. (pieceStorage): New variable. (peerStorage): New variable. (btAnnounce): New variable. (btProgressInfoFile): New variable. (torrentMan): Removed. (setBtContext): New function. * src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, pieceStorage, peerStorage, btAnnounce, btProgressInfoFile. * src/Piece.h (toString): New function. (Pieces): New type definition. * src/Peer.h (active): New variable. (Peer): Added active. (activate): Set active to true. (deactivate): Set active to false. (isActive): New function. (Peers): New type definition. * src/DirectDiskAdaptor.cc (getFilePath): Use the accessor methods of FileEntry. * src/TorrentConsoleDownloadEngine.h (afterEachIteration): New function. * src/TorrentConsoleDownloadEngine.cc (haltRequested): New variable. (sendStatistics): Use pieceStorage, btRuntime. (afterEachIteration): New function. * src/AnnounceList: AnnounceTier->AnnounceTierHandle. * src/Directry.h (Directory): New function. (DirectoryHandle): New type definition. * src/BtProgressInfoFile.h: New file. * src/RequestMessage.cc: Use pieceStorage. * src/BtRuntime.h: New file. * src/DefaultBtContext.cc: New file. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/MultiDiskAdaptor.cc (mkdir): New function. (openFile): Call mkdir(). (initAndOpenFile): Call mkdir(). * src/CancelMessage.h (TorrentMan.h): Removed. * src/RejectMessage.h (TorrentMan.h): Removed. * src/DownloadEngineFactory.cc (DefaultPieceStorage.h): New include. (DefaultPeerStorage.h): New include. (DefaultBtAnnounce.h): New include. (DefaultBtProgressInfoFile.h): New include. (newTorrentConsoleEngine): Rewritten. * src/ShareRatioSeedCriteria.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (btRuntime): New variable. (evaluate): Use btContext, btRuntime, peerStorage. * src/AnnounceTier.h: New file. * src/BtAnnounce.h: New file. * src/BtRegistry.h: New file. * src/PeerInitiateConnectionCommand.h: Added btContext. * src/PeerConnection.h (TorrentMan.h): Removed. * src/PeerMessageFactory.cc: Use btContext, pieceStorage. * src/Util.h (slice): Added an argument. * src/Util.cc (slice): Added an argument to control whether trim is made or not. * src/PeerStorage.h: New file. * src/BtRegistry.cc: New file. * src/TrackerUpdateCommand.h: Made subclass of BtContextAwareCommand. * src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry. * src/MultiDiskWriter.h: FileEntry -> FileEntryHandle * src/PeerListenCommand.cc: Use btRuntime, peerStorage, btContext. * src/TorrentRequestInfo.h (e): Removed. (showFileEntry): Added an argument. (getDownloadEngine): Return 0. * src/DefaultBtAnnounce.h: New file. * src/TorrentAutoSaveCommand.cc: Use btRuntime, btProgressInfoFile. * src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce, * src/PeerMessageFactory.h (btContext): New variable. (pieceStorage): New variable. * src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, btContext, btAnnounce. * src/DiskAdaptor.cc (DiskAdaptor): Removed topDir. (~DiskAdaptor): Removed topDir. * src/PeerListenCommand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.h: Made subclass of BtContextAwareCommand. * src/File.h (mkdirs): New function. * src/DefaultPeerStorage): New file. * src/DownloadEngineFactory.h (newTorrentConsoleEngine): Use btContext. * src/BtContextAwareCommand.cc: New file. * src/PeerInitiateConnectionCommand.cc: Use btRuntime, peerStorage. * src/PeerMessage.h (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (setBtContext): New function. * src/Directry.cc (Directory): New function. (createDir): Do nothing if name.size() == 0. * src/AnnounceList.h (AnnounceTier): Removed. (AnnounceTiers): Removed. * src/DefaultPieceStorage.h: New file. * src/Piece.cc (toString): New function. To fix typo: * src/main.cc (showVersion): Fixed typo. To fix compile warning: * src/DelegatingPeerListProcessor.cc (canHandle): Added "return false".
2006-11-05 15:04:17 +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 "FileEntry.h"
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
#include <cassert>
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
#include <algorithm>
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
#include "util.h"
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
#include "URISelector.h"
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
#include "LogFactory.h"
#include "wallclock.h"
2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> To divide TorrentMan into 6 classes: BtContext, BtRuntime, PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile * src/TrackerWatcherComand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.cc: Use pieceStorage, btRuntime * src/PeerAbstractCommand.h: Made subclass of BtContextAwareCommand. * src/PeerAbstractCommand.cc: Use btRuntime. * src/BtContextAwareCommand.h: New class. * src/FileEntry.h: Added accessor methods for following variables. (path): Made private. (length): Made private. (offset): Made private. (extracted): Made private. (requested): Made private. (FileEntries): New definition. (FileEntryHandle): New definition. * src/FileEntry.cc: New file. * src/HaveEraseCommand.h: Made subclass of BtContextAwareCommand. * src/HaveEraseCommand.cc: Use btRuntime, pieceStorage. * src/PeerChokeCommand.h: Made subclass of BtContextAwareCommand. * src/PeerChokeCommand.cc: Use btRuntime, peerStorage, pieceStorage. * src/PieceStorage.h: New file. * src/PeerInteractionCommand.h: Use btContext. * src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage, btRuntime. * src/DefaultBtProgressInfoFile.h: New file. * src/DefaultBtProgressInfoFile.cc: New file. * src/File.cc (Util.h): New include. (mkdirs): New function. * src/MultiDiskAdaptor.h (mkdir): New function. * src/PeerListProcessor.h (Peers): Removed. * src/PeerInteraction.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (btAnnounce): New variable. (getTorrentMan): Removed. (getBtContext): New function. * src/PeerInteraction.cc: Use btContext, peerStorage, pieceStorage, btAnnounce. * src/HandshakeMessage.h (TorrentMan.h): Removed. * src/HandshakeMessage.cc: Use btContext. * src/DefaultBtAnnounce.cc: New file. * src/MultiDiskWriter.cc: Use the accessor methods of FileEntry. * src/DefaultPieceStorage.cc: New file. * src/DefaultBtContext.h: New file. * src/TorrentRequestInfo.cc: Use btContext, pieceStorage. Use the accessor methods of FileEntry. * src/CookieBox.cc: Updated to use Util::slice(). * src/PieceMessage.cc: Use btContext, pieceStorage. * src/common.h (SharedHandle.h): New include. * src/PeerMessage.cc (PeerMessage): Added btContext, peerStorage, pieceStorage. * src/TorrentAutoSaveCommand.h: Made subclass of BtContextAwareCommand. * src/DiskAdaptor.h (topDir): Removed. (getFileEntryFromPath): Changed the return type to FileEntryHandle. (setTopDir): Removed. (getTopDir): Removed. * src/BtContext.h: New file. * src/DefaultPeerStorage.h: New file. * src/PieceMessage.h (TorrentMan.h): Removed. * src/RequestMessage.h (TorrentMan.h): Removed. * src/TorrentDownloadEngine.h (uploadLength): New variable. (btContext): New variable. (btRuntime): New variable. (pieceStorage): New variable. (peerStorage): New variable. (btAnnounce): New variable. (btProgressInfoFile): New variable. (torrentMan): Removed. (setBtContext): New function. * src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, pieceStorage, peerStorage, btAnnounce, btProgressInfoFile. * src/Piece.h (toString): New function. (Pieces): New type definition. * src/Peer.h (active): New variable. (Peer): Added active. (activate): Set active to true. (deactivate): Set active to false. (isActive): New function. (Peers): New type definition. * src/DirectDiskAdaptor.cc (getFilePath): Use the accessor methods of FileEntry. * src/TorrentConsoleDownloadEngine.h (afterEachIteration): New function. * src/TorrentConsoleDownloadEngine.cc (haltRequested): New variable. (sendStatistics): Use pieceStorage, btRuntime. (afterEachIteration): New function. * src/AnnounceList: AnnounceTier->AnnounceTierHandle. * src/Directry.h (Directory): New function. (DirectoryHandle): New type definition. * src/BtProgressInfoFile.h: New file. * src/RequestMessage.cc: Use pieceStorage. * src/BtRuntime.h: New file. * src/DefaultBtContext.cc: New file. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/MultiDiskAdaptor.cc (mkdir): New function. (openFile): Call mkdir(). (initAndOpenFile): Call mkdir(). * src/CancelMessage.h (TorrentMan.h): Removed. * src/RejectMessage.h (TorrentMan.h): Removed. * src/DownloadEngineFactory.cc (DefaultPieceStorage.h): New include. (DefaultPeerStorage.h): New include. (DefaultBtAnnounce.h): New include. (DefaultBtProgressInfoFile.h): New include. (newTorrentConsoleEngine): Rewritten. * src/ShareRatioSeedCriteria.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (btRuntime): New variable. (evaluate): Use btContext, btRuntime, peerStorage. * src/AnnounceTier.h: New file. * src/BtAnnounce.h: New file. * src/BtRegistry.h: New file. * src/PeerInitiateConnectionCommand.h: Added btContext. * src/PeerConnection.h (TorrentMan.h): Removed. * src/PeerMessageFactory.cc: Use btContext, pieceStorage. * src/Util.h (slice): Added an argument. * src/Util.cc (slice): Added an argument to control whether trim is made or not. * src/PeerStorage.h: New file. * src/BtRegistry.cc: New file. * src/TrackerUpdateCommand.h: Made subclass of BtContextAwareCommand. * src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry. * src/MultiDiskWriter.h: FileEntry -> FileEntryHandle * src/PeerListenCommand.cc: Use btRuntime, peerStorage, btContext. * src/TorrentRequestInfo.h (e): Removed. (showFileEntry): Added an argument. (getDownloadEngine): Return 0. * src/DefaultBtAnnounce.h: New file. * src/TorrentAutoSaveCommand.cc: Use btRuntime, btProgressInfoFile. * src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce, * src/PeerMessageFactory.h (btContext): New variable. (pieceStorage): New variable. * src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, btContext, btAnnounce. * src/DiskAdaptor.cc (DiskAdaptor): Removed topDir. (~DiskAdaptor): Removed topDir. * src/PeerListenCommand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.h: Made subclass of BtContextAwareCommand. * src/File.h (mkdirs): New function. * src/DefaultPeerStorage): New file. * src/DownloadEngineFactory.h (newTorrentConsoleEngine): Use btContext. * src/BtContextAwareCommand.cc: New file. * src/PeerInitiateConnectionCommand.cc: Use btRuntime, peerStorage. * src/PeerMessage.h (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (setBtContext): New function. * src/Directry.cc (Directory): New function. (createDir): Do nothing if name.size() == 0. * src/AnnounceList.h (AnnounceTier): Removed. (AnnounceTiers): Removed. * src/DefaultPieceStorage.h: New file. * src/Piece.cc (toString): New function. To fix typo: * src/main.cc (showVersion): Fixed typo. To fix compile warning: * src/DelegatingPeerListProcessor.cc (canHandle): Added "return false".
2006-11-05 15:04:17 +00:00
namespace aria2 {
FileEntry::FileEntry(const std::string& path,
uint64_t length,
off_t offset,
const std::vector<std::string>& uris):
path_(path), uris_(uris.begin(), uris.end()), length_(length),
offset_(offset),
requested_(true),
uniqueProtocol_(false),
maxConnectionPerServer_(1),
lastFasterReplace_(0),
logger_(LogFactory::getInstance()) {}
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
FileEntry::FileEntry():
length_(0), offset_(0), requested_(false),
uniqueProtocol_(false),
maxConnectionPerServer_(1),
logger_(LogFactory::getInstance()) {}
2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> To divide TorrentMan into 6 classes: BtContext, BtRuntime, PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile * src/TrackerWatcherComand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.cc: Use pieceStorage, btRuntime * src/PeerAbstractCommand.h: Made subclass of BtContextAwareCommand. * src/PeerAbstractCommand.cc: Use btRuntime. * src/BtContextAwareCommand.h: New class. * src/FileEntry.h: Added accessor methods for following variables. (path): Made private. (length): Made private. (offset): Made private. (extracted): Made private. (requested): Made private. (FileEntries): New definition. (FileEntryHandle): New definition. * src/FileEntry.cc: New file. * src/HaveEraseCommand.h: Made subclass of BtContextAwareCommand. * src/HaveEraseCommand.cc: Use btRuntime, pieceStorage. * src/PeerChokeCommand.h: Made subclass of BtContextAwareCommand. * src/PeerChokeCommand.cc: Use btRuntime, peerStorage, pieceStorage. * src/PieceStorage.h: New file. * src/PeerInteractionCommand.h: Use btContext. * src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage, btRuntime. * src/DefaultBtProgressInfoFile.h: New file. * src/DefaultBtProgressInfoFile.cc: New file. * src/File.cc (Util.h): New include. (mkdirs): New function. * src/MultiDiskAdaptor.h (mkdir): New function. * src/PeerListProcessor.h (Peers): Removed. * src/PeerInteraction.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (btAnnounce): New variable. (getTorrentMan): Removed. (getBtContext): New function. * src/PeerInteraction.cc: Use btContext, peerStorage, pieceStorage, btAnnounce. * src/HandshakeMessage.h (TorrentMan.h): Removed. * src/HandshakeMessage.cc: Use btContext. * src/DefaultBtAnnounce.cc: New file. * src/MultiDiskWriter.cc: Use the accessor methods of FileEntry. * src/DefaultPieceStorage.cc: New file. * src/DefaultBtContext.h: New file. * src/TorrentRequestInfo.cc: Use btContext, pieceStorage. Use the accessor methods of FileEntry. * src/CookieBox.cc: Updated to use Util::slice(). * src/PieceMessage.cc: Use btContext, pieceStorage. * src/common.h (SharedHandle.h): New include. * src/PeerMessage.cc (PeerMessage): Added btContext, peerStorage, pieceStorage. * src/TorrentAutoSaveCommand.h: Made subclass of BtContextAwareCommand. * src/DiskAdaptor.h (topDir): Removed. (getFileEntryFromPath): Changed the return type to FileEntryHandle. (setTopDir): Removed. (getTopDir): Removed. * src/BtContext.h: New file. * src/DefaultPeerStorage.h: New file. * src/PieceMessage.h (TorrentMan.h): Removed. * src/RequestMessage.h (TorrentMan.h): Removed. * src/TorrentDownloadEngine.h (uploadLength): New variable. (btContext): New variable. (btRuntime): New variable. (pieceStorage): New variable. (peerStorage): New variable. (btAnnounce): New variable. (btProgressInfoFile): New variable. (torrentMan): Removed. (setBtContext): New function. * src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, pieceStorage, peerStorage, btAnnounce, btProgressInfoFile. * src/Piece.h (toString): New function. (Pieces): New type definition. * src/Peer.h (active): New variable. (Peer): Added active. (activate): Set active to true. (deactivate): Set active to false. (isActive): New function. (Peers): New type definition. * src/DirectDiskAdaptor.cc (getFilePath): Use the accessor methods of FileEntry. * src/TorrentConsoleDownloadEngine.h (afterEachIteration): New function. * src/TorrentConsoleDownloadEngine.cc (haltRequested): New variable. (sendStatistics): Use pieceStorage, btRuntime. (afterEachIteration): New function. * src/AnnounceList: AnnounceTier->AnnounceTierHandle. * src/Directry.h (Directory): New function. (DirectoryHandle): New type definition. * src/BtProgressInfoFile.h: New file. * src/RequestMessage.cc: Use pieceStorage. * src/BtRuntime.h: New file. * src/DefaultBtContext.cc: New file. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/MultiDiskAdaptor.cc (mkdir): New function. (openFile): Call mkdir(). (initAndOpenFile): Call mkdir(). * src/CancelMessage.h (TorrentMan.h): Removed. * src/RejectMessage.h (TorrentMan.h): Removed. * src/DownloadEngineFactory.cc (DefaultPieceStorage.h): New include. (DefaultPeerStorage.h): New include. (DefaultBtAnnounce.h): New include. (DefaultBtProgressInfoFile.h): New include. (newTorrentConsoleEngine): Rewritten. * src/ShareRatioSeedCriteria.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (btRuntime): New variable. (evaluate): Use btContext, btRuntime, peerStorage. * src/AnnounceTier.h: New file. * src/BtAnnounce.h: New file. * src/BtRegistry.h: New file. * src/PeerInitiateConnectionCommand.h: Added btContext. * src/PeerConnection.h (TorrentMan.h): Removed. * src/PeerMessageFactory.cc: Use btContext, pieceStorage. * src/Util.h (slice): Added an argument. * src/Util.cc (slice): Added an argument to control whether trim is made or not. * src/PeerStorage.h: New file. * src/BtRegistry.cc: New file. * src/TrackerUpdateCommand.h: Made subclass of BtContextAwareCommand. * src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry. * src/MultiDiskWriter.h: FileEntry -> FileEntryHandle * src/PeerListenCommand.cc: Use btRuntime, peerStorage, btContext. * src/TorrentRequestInfo.h (e): Removed. (showFileEntry): Added an argument. (getDownloadEngine): Return 0. * src/DefaultBtAnnounce.h: New file. * src/TorrentAutoSaveCommand.cc: Use btRuntime, btProgressInfoFile. * src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce, * src/PeerMessageFactory.h (btContext): New variable. (pieceStorage): New variable. * src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, btContext, btAnnounce. * src/DiskAdaptor.cc (DiskAdaptor): Removed topDir. (~DiskAdaptor): Removed topDir. * src/PeerListenCommand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.h: Made subclass of BtContextAwareCommand. * src/File.h (mkdirs): New function. * src/DefaultPeerStorage): New file. * src/DownloadEngineFactory.h (newTorrentConsoleEngine): Use btContext. * src/BtContextAwareCommand.cc: New file. * src/PeerInitiateConnectionCommand.cc: Use btRuntime, peerStorage. * src/PeerMessage.h (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (setBtContext): New function. * src/Directry.cc (Directory): New function. (createDir): Do nothing if name.size() == 0. * src/AnnounceList.h (AnnounceTier): Removed. (AnnounceTiers): Removed. * src/DefaultPieceStorage.h: New file. * src/Piece.cc (toString): New function. To fix typo: * src/main.cc (showVersion): Fixed typo. To fix compile warning: * src/DelegatingPeerListProcessor.cc (canHandle): Added "return false".
2006-11-05 15:04:17 +00:00
FileEntry::~FileEntry() {}
void FileEntry::setupDir()
{
util::mkdirs(File(path_).getDirname());
2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> To divide TorrentMan into 6 classes: BtContext, BtRuntime, PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile * src/TrackerWatcherComand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.cc: Use pieceStorage, btRuntime * src/PeerAbstractCommand.h: Made subclass of BtContextAwareCommand. * src/PeerAbstractCommand.cc: Use btRuntime. * src/BtContextAwareCommand.h: New class. * src/FileEntry.h: Added accessor methods for following variables. (path): Made private. (length): Made private. (offset): Made private. (extracted): Made private. (requested): Made private. (FileEntries): New definition. (FileEntryHandle): New definition. * src/FileEntry.cc: New file. * src/HaveEraseCommand.h: Made subclass of BtContextAwareCommand. * src/HaveEraseCommand.cc: Use btRuntime, pieceStorage. * src/PeerChokeCommand.h: Made subclass of BtContextAwareCommand. * src/PeerChokeCommand.cc: Use btRuntime, peerStorage, pieceStorage. * src/PieceStorage.h: New file. * src/PeerInteractionCommand.h: Use btContext. * src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage, btRuntime. * src/DefaultBtProgressInfoFile.h: New file. * src/DefaultBtProgressInfoFile.cc: New file. * src/File.cc (Util.h): New include. (mkdirs): New function. * src/MultiDiskAdaptor.h (mkdir): New function. * src/PeerListProcessor.h (Peers): Removed. * src/PeerInteraction.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (btAnnounce): New variable. (getTorrentMan): Removed. (getBtContext): New function. * src/PeerInteraction.cc: Use btContext, peerStorage, pieceStorage, btAnnounce. * src/HandshakeMessage.h (TorrentMan.h): Removed. * src/HandshakeMessage.cc: Use btContext. * src/DefaultBtAnnounce.cc: New file. * src/MultiDiskWriter.cc: Use the accessor methods of FileEntry. * src/DefaultPieceStorage.cc: New file. * src/DefaultBtContext.h: New file. * src/TorrentRequestInfo.cc: Use btContext, pieceStorage. Use the accessor methods of FileEntry. * src/CookieBox.cc: Updated to use Util::slice(). * src/PieceMessage.cc: Use btContext, pieceStorage. * src/common.h (SharedHandle.h): New include. * src/PeerMessage.cc (PeerMessage): Added btContext, peerStorage, pieceStorage. * src/TorrentAutoSaveCommand.h: Made subclass of BtContextAwareCommand. * src/DiskAdaptor.h (topDir): Removed. (getFileEntryFromPath): Changed the return type to FileEntryHandle. (setTopDir): Removed. (getTopDir): Removed. * src/BtContext.h: New file. * src/DefaultPeerStorage.h: New file. * src/PieceMessage.h (TorrentMan.h): Removed. * src/RequestMessage.h (TorrentMan.h): Removed. * src/TorrentDownloadEngine.h (uploadLength): New variable. (btContext): New variable. (btRuntime): New variable. (pieceStorage): New variable. (peerStorage): New variable. (btAnnounce): New variable. (btProgressInfoFile): New variable. (torrentMan): Removed. (setBtContext): New function. * src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, pieceStorage, peerStorage, btAnnounce, btProgressInfoFile. * src/Piece.h (toString): New function. (Pieces): New type definition. * src/Peer.h (active): New variable. (Peer): Added active. (activate): Set active to true. (deactivate): Set active to false. (isActive): New function. (Peers): New type definition. * src/DirectDiskAdaptor.cc (getFilePath): Use the accessor methods of FileEntry. * src/TorrentConsoleDownloadEngine.h (afterEachIteration): New function. * src/TorrentConsoleDownloadEngine.cc (haltRequested): New variable. (sendStatistics): Use pieceStorage, btRuntime. (afterEachIteration): New function. * src/AnnounceList: AnnounceTier->AnnounceTierHandle. * src/Directry.h (Directory): New function. (DirectoryHandle): New type definition. * src/BtProgressInfoFile.h: New file. * src/RequestMessage.cc: Use pieceStorage. * src/BtRuntime.h: New file. * src/DefaultBtContext.cc: New file. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/BitfieldMan.h (getCompletedLength): New function(private). (getCompletedLength): New function. (getFilteredCompletedLength): New function. * src/MultiDiskAdaptor.cc (mkdir): New function. (openFile): Call mkdir(). (initAndOpenFile): Call mkdir(). * src/CancelMessage.h (TorrentMan.h): Removed. * src/RejectMessage.h (TorrentMan.h): Removed. * src/DownloadEngineFactory.cc (DefaultPieceStorage.h): New include. (DefaultPeerStorage.h): New include. (DefaultBtAnnounce.h): New include. (DefaultBtProgressInfoFile.h): New include. (newTorrentConsoleEngine): Rewritten. * src/ShareRatioSeedCriteria.h (torrentMan): Removed. (btContext): New variable. (peerStorage): New variable. (btRuntime): New variable. (evaluate): Use btContext, btRuntime, peerStorage. * src/AnnounceTier.h: New file. * src/BtAnnounce.h: New file. * src/BtRegistry.h: New file. * src/PeerInitiateConnectionCommand.h: Added btContext. * src/PeerConnection.h (TorrentMan.h): Removed. * src/PeerMessageFactory.cc: Use btContext, pieceStorage. * src/Util.h (slice): Added an argument. * src/Util.cc (slice): Added an argument to control whether trim is made or not. * src/PeerStorage.h: New file. * src/BtRegistry.cc: New file. * src/TrackerUpdateCommand.h: Made subclass of BtContextAwareCommand. * src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry. * src/MultiDiskWriter.h: FileEntry -> FileEntryHandle * src/PeerListenCommand.cc: Use btRuntime, peerStorage, btContext. * src/TorrentRequestInfo.h (e): Removed. (showFileEntry): Added an argument. (getDownloadEngine): Return 0. * src/DefaultBtAnnounce.h: New file. * src/TorrentAutoSaveCommand.cc: Use btRuntime, btProgressInfoFile. * src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce, * src/PeerMessageFactory.h (btContext): New variable. (pieceStorage): New variable. * src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, btContext, btAnnounce. * src/DiskAdaptor.cc (DiskAdaptor): Removed topDir. (~DiskAdaptor): Removed topDir. * src/PeerListenCommand.h: Made subclass of BtContextAwareCommand. * src/SeedCheckCommand.h: Made subclass of BtContextAwareCommand. * src/File.h (mkdirs): New function. * src/DefaultPeerStorage): New file. * src/DownloadEngineFactory.h (newTorrentConsoleEngine): Use btContext. * src/BtContextAwareCommand.cc: New file. * src/PeerInitiateConnectionCommand.cc: Use btRuntime, peerStorage. * src/PeerMessage.h (btContext): New variable. (peerStorage): New variable. (pieceStorage): New variable. (setBtContext): New function. * src/Directry.cc (Directory): New function. (createDir): Do nothing if name.size() == 0. * src/AnnounceList.h (AnnounceTier): Removed. (AnnounceTiers): Removed. * src/DefaultPieceStorage.h: New file. * src/Piece.cc (toString): New function. To fix typo: * src/main.cc (showVersion): Fixed typo. To fix compile warning: * src/DelegatingPeerListProcessor.cc (canHandle): Added "return false".
2006-11-05 15:04:17 +00:00
}
FileEntry& FileEntry::operator=(const FileEntry& entry)
{
if(this != &entry) {
path_ = entry.path_;
length_ = entry.length_;
offset_ = entry.offset_;
requested_ = entry.requested_;
}
return *this;
}
2007-11-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> Preallocate non-requested file which is adjacent forward to requested file('requested' files means the files given in --select-file option) if they share a same piece. This fixes long pause in the file system which doesn't support sparse files like FAT32 while downloading. * src/MultiFileAllocationIterator.{h, cc} * test/MultiFileAllocationIteratorTest.cc * src/FileEntry.{h, cc} Removed unused _option. * src/MultiDiskAdaptor.h * test/MultiDiskAdaptorTest.cc * src/DefaultPieceStorage.cc Set the default value of --seed-ratio to 1.0. If 0.0 is given, then seeding continues regardless of share ratio. * src/version_usage.cc * src/option_processing.cc * src/BtSetup.cc * doc/aria2c.1.txt * doc/aria2c.1 Fixed: Selective download is not working in BitTorrent * src/RequestGroup.cc Introduced Sequence class. Use this instead of Util::unfoldRange() * src/PieceStorage.h * test/MockPieceStorage.h * src/UnknownLengthPieceStorage.h * src/DefaultPieceStorage.{h, cc} * src/Metalink2RequestGroup.cc * src/RequestGroup.cc * src/Sequence.h * test/SequenceTest.cc * src/IntSequence.h * src/message.h * src/Util.{h, cc} * test/UtilTest.cc Added new function 'parse' to catch exception thrown by subclass's parseArg * src/OptionHandler.h * src/OptionParser.cc * src/NameMatchOptionHandler.h * src/OptionHandlerImpl.h * test/OptionHandlerTest.cc Added IntegerRangeOptionHandler. Used for --listen-port and --select-file. Now --listen-port accepts range of port. * src/OptionHandlerFactory.cc * src/version_usage.cc * src/OptionHandlerImpl.h * src/option_processing.cc * src/BtSetup.cc * src/PeerListenCommand.{h, cc} * doc/aria2c.1.txt * doc/aria2c.1 Implemented operator< for Exception class to provide easy way to print exception stack trace. * src/Exception.{h, cc} * src/main.cc * src/option_processing.cc
2007-11-21 16:14:40 +00:00
bool FileEntry::operator<(const FileEntry& fileEntry) const
{
return offset_ < fileEntry.offset_;
2007-11-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> Preallocate non-requested file which is adjacent forward to requested file('requested' files means the files given in --select-file option) if they share a same piece. This fixes long pause in the file system which doesn't support sparse files like FAT32 while downloading. * src/MultiFileAllocationIterator.{h, cc} * test/MultiFileAllocationIteratorTest.cc * src/FileEntry.{h, cc} Removed unused _option. * src/MultiDiskAdaptor.h * test/MultiDiskAdaptorTest.cc * src/DefaultPieceStorage.cc Set the default value of --seed-ratio to 1.0. If 0.0 is given, then seeding continues regardless of share ratio. * src/version_usage.cc * src/option_processing.cc * src/BtSetup.cc * doc/aria2c.1.txt * doc/aria2c.1 Fixed: Selective download is not working in BitTorrent * src/RequestGroup.cc Introduced Sequence class. Use this instead of Util::unfoldRange() * src/PieceStorage.h * test/MockPieceStorage.h * src/UnknownLengthPieceStorage.h * src/DefaultPieceStorage.{h, cc} * src/Metalink2RequestGroup.cc * src/RequestGroup.cc * src/Sequence.h * test/SequenceTest.cc * src/IntSequence.h * src/message.h * src/Util.{h, cc} * test/UtilTest.cc Added new function 'parse' to catch exception thrown by subclass's parseArg * src/OptionHandler.h * src/OptionParser.cc * src/NameMatchOptionHandler.h * src/OptionHandlerImpl.h * test/OptionHandlerTest.cc Added IntegerRangeOptionHandler. Used for --listen-port and --select-file. Now --listen-port accepts range of port. * src/OptionHandlerFactory.cc * src/version_usage.cc * src/OptionHandlerImpl.h * src/option_processing.cc * src/BtSetup.cc * src/PeerListenCommand.{h, cc} * doc/aria2c.1.txt * doc/aria2c.1 Implemented operator< for Exception class to provide easy way to print exception stack trace. * src/Exception.{h, cc} * src/main.cc * src/option_processing.cc
2007-11-21 16:14:40 +00:00
}
bool FileEntry::exists() const
{
return File(getPath()).exists();
}
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
off_t FileEntry::gtoloff(off_t goff) const
{
assert(offset_ <= goff);
return goff-offset_;
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
}
void FileEntry::getUris(std::vector<std::string>& uris) const
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
{
uris.insert(uris.end(), spentUris_.begin(), spentUris_.end());
uris.insert(uris.end(), uris_.begin(), uris_.end());
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
}
std::string FileEntry::selectUri(const SharedHandle<URISelector>& uriSelector)
{
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
return uriSelector->select(this);
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
}
template<typename InputIterator>
static size_t countInFlightHost(InputIterator first, InputIterator last,
const std::string& hostname)
{
// TODO redirection should be considered here. We need to parse
// original URI to get hostname.
size_t count = 0;
for(; first != last; ++first) {
if((*first)->getHost() == hostname) {
++count;
}
}
return count;
}
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
SharedHandle<Request>
FileEntry::getRequest
(const SharedHandle<URISelector>& selector,
bool uriReuse,
const std::string& referer,
const std::string& method)
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
{
SharedHandle<Request> req;
if(requestPool_.empty()) {
for(int g = 0; g < 2; ++g) {
std::vector<std::string> pending;
std::vector<std::string> ignoreHost;
while(1) {
std::string uri = selector->select(this);
if(uri.empty()) {
break;
}
req.reset(new Request());
if(req->setUri(uri)) {
if(countInFlightHost(inFlightRequests_.begin(),
inFlightRequests_.end(),
req->getHost()) >= maxConnectionPerServer_) {
pending.push_back(uri);
ignoreHost.push_back(req->getHost());
req.reset();
continue;
}
req->setReferer(referer);
req->setMethod(method);
spentUris_.push_back(uri);
inFlightRequests_.push_back(req);
break;
} else {
req.reset();
}
}
uris_.insert(uris_.begin(), pending.begin(), pending.end());
// TODO UriReuse is performed only when PREF_REUSE_URI is true.
if(g == 0 && uriReuse && req.isNull() && uris_.size() == pending.size()) {
// Reuse URIs other than ones in pending
reuseUri(ignoreHost);
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
} else {
break;
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
}
}
} else {
req = requestPool_.front();
requestPool_.pop_front();
inFlightRequests_.push_back(req);
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
}
return req;
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
}
SharedHandle<Request>
FileEntry::findFasterRequest(const SharedHandle<Request>& base)
{
const int startupIdleTime = 10;
if(requestPool_.empty() ||
lastFasterReplace_.difference(global::wallclock) < startupIdleTime) {
return SharedHandle<Request>();
}
const SharedHandle<PeerStat>& fastest = requestPool_.front()->getPeerStat();
if(fastest.isNull()) {
return SharedHandle<Request>();
}
const SharedHandle<PeerStat>& basestat = base->getPeerStat();
// TODO hard coded value. See PREF_STARTUP_IDLE_TIME
if(basestat.isNull() ||
(basestat->getDownloadStartTime().
difference(global::wallclock) >= startupIdleTime &&
fastest->getAvgDownloadSpeed()*0.8 > basestat->calculateDownloadSpeed())){
// TODO we should consider that "fastest" is very slow.
SharedHandle<Request> fastestRequest = requestPool_.front();
requestPool_.pop_front();
inFlightRequests_.push_back(fastestRequest);
lastFasterReplace_.reset();
return fastestRequest;
}
return SharedHandle<Request>();
}
class RequestFaster {
public:
bool operator()(const SharedHandle<Request>& lhs,
const SharedHandle<Request>& rhs) const
{
if(lhs->getPeerStat().isNull()) {
return false;
}
if(rhs->getPeerStat().isNull()) {
return true;
}
return
lhs->getPeerStat()->getAvgDownloadSpeed() > rhs->getPeerStat()->getAvgDownloadSpeed();
}
};
void FileEntry::storePool(const SharedHandle<Request>& request)
{
const SharedHandle<PeerStat>& peerStat = request->getPeerStat();
if(!peerStat.isNull()) {
// We need to calculate average download speed here in order to
// store Request in the right position in the pool.
peerStat->calculateAvgDownloadSpeed();
}
std::deque<SharedHandle<Request> >::iterator i =
std::lower_bound(requestPool_.begin(), requestPool_.end(), request,
RequestFaster());
requestPool_.insert(i, request);
}
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
void FileEntry::poolRequest(const SharedHandle<Request>& request)
{
removeRequest(request);
if(!request->removalRequested()) {
storePool(request);
}
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
}
bool FileEntry::removeRequest(const SharedHandle<Request>& request)
{
for(std::deque<SharedHandle<Request> >::iterator i =
inFlightRequests_.begin(), eoi = inFlightRequests_.end();
i != eoi; ++i) {
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
if((*i).get() == request.get()) {
inFlightRequests_.erase(i);
2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Added experimental support of WEB-Seeding for multi-file torrent. Due to fundamental changes in file handling in HTTP/FTP code, many functions are not working: PeerStat, ServerHost, proxy..etc * src/AbstractCommand.cc * src/AbstractCommand.h * src/BitfieldMan.cc * src/BitfieldMan.h * src/CreateRequestCommand.cc * src/CreateRequestCommand.h * src/DefaultPieceStorage.cc * src/DefaultPieceStorage.h * src/DownloadCommand.cc * src/DownloadCommand.h * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/FtpDownloadCommand.cc * src/FtpDownloadCommand.h * src/FtpFinishDownloadCommand.cc * src/FtpFinishDownloadCommand.h * src/FtpInitiateConnectionCommand.cc * src/FtpInitiateConnectionCommand.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * src/FtpTunnelResponseCommand.cc * src/HttpDownloadCommand.cc * src/HttpDownloadCommand.h * src/HttpInitiateConnectionCommand.cc * src/HttpInitiateConnectionCommand.h * src/HttpProxyResponseCommand.cc * src/HttpRequest.cc * src/HttpRequest.h * src/HttpRequestCommand.cc * src/HttpRequestCommand.h * src/HttpResponseCommand.cc * src/HttpResponseCommand.h * src/HttpSkipResponseCommand.cc * src/HttpSkipResponseCommand.h * src/InitiateConnectionCommand.cc * src/InitiateConnectionCommand.h * src/InitiateConnectionCommandFactory.cc * src/InitiateConnectionCommandFactory.h * src/Makefile.am * src/PieceStorage.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SegmentMan.h * src/SingleFileDownloadContext.h * src/StreamFileAllocationEntry.cc * src/TrackerWatcherCommand.cc * src/UnknownLengthPieceStorage.cc * src/UnknownLengthPieceStorage.h * src/array_fun.h * src/bitfield.h * src/download_helper.cc * test/DownloadContextTest.cc * test/Makefile.am * test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
return true;
}
}
return false;
}
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
void FileEntry::removeURIWhoseHostnameIs(const std::string& hostname)
{
std::deque<std::string> newURIs;
Request req;
for(std::deque<std::string>::const_iterator itr = uris_.begin(),
eoi = uris_.end(); itr != eoi; ++itr) {
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
if(((*itr).find(hostname) == std::string::npos) ||
(req.setUri(*itr) && (req.getHost() != hostname))) {
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
newURIs.push_back(*itr);
}
}
if(logger_->debug()) {
logger_->debug("Removed %d duplicate hostname URIs for path=%s",
uris_.size()-newURIs.size(), getPath().c_str());
2010-02-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Wrapped logger->debug(...) with if(logger->debug()) { ... } * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/BtPieceMessage.cc * src/BtPortMessage.cc * src/CreateRequestCommand.cc * src/DHTAbstractNodeLookupTask.cc * src/DHTBucket.cc * src/DHTGetPeersCommand.cc * src/DHTMessageDispatcherImpl.cc * src/DHTMessageFactoryImpl.cc * src/DHTMessageTracker.cc * src/DHTPeerAnnounceStorage.cc * src/DHTRoutingTable.cc * src/DHTSetup.cc * src/DefaultBtAnnounce.cc * src/DefaultBtInteractive.cc * src/DefaultBtMessageDispatcher.cc * src/DefaultBtMessageReceiver.cc * src/DefaultBtProgressInfoFile.cc * src/DefaultBtRequestFactory.cc * src/DefaultPeerStorage.cc * src/DefaultPieceStorage.cc * src/DownloadCommand.cc * src/DownloadEngine.cc * src/EpollEventPoll.cc * src/FileAllocationCommand.cc * src/FileEntry.cc * src/FtpNegotiationCommand.cc * src/HandshakeExtensionMessage.cc * src/HttpListenCommand.cc * src/HttpServer.cc * src/HttpSkipResponseCommand.cc * src/IteratableChunkChecksumValidator.cc * src/Logger.h * src/MSEHandshake.cc * src/MetalinkPostDownloadHandler.cc * src/MultiDiskAdaptor.cc * src/PeerAbstractCommand.cc * src/PeerConnection.cc * src/PeerListenCommand.cc * src/PeerReceiveHandshakeCommand.cc * src/RequestGroup.cc * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SelectEventPoll.cc * src/ServerStat.cc * src/SimpleBtMessage.cc * src/SocketCore.cc * src/TrackerWatcherCommand.cc * src/UTMetadataDataExtensionMessage.cc * src/UTMetadataRequestFactory.cc * src/UTMetadataRequestTracker.cc * src/XmlRpcMethod.cc
2010-02-09 12:20:20 +00:00
}
uris_ = newURIs;
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
}
void FileEntry::removeIdenticalURI(const std::string& uri)
{
uris_.erase(std::remove(uris_.begin(), uris_.end(), uri), uris_.end());
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
}
void FileEntry::addURIResult(std::string uri, downloadresultcode::RESULT result)
{
uriResults_.push_back(URIResult(uri, result));
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
}
class FindURIResultByResult {
private:
downloadresultcode::RESULT r_;
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
public:
FindURIResultByResult(downloadresultcode::RESULT r):r_(r) {}
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
bool operator()(const URIResult& uriResult) const
{
return uriResult.getResult() == r_;
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
}
};
void FileEntry::extractURIResult
(std::deque<URIResult>& res, downloadresultcode::RESULT r)
{
std::deque<URIResult>::iterator i =
std::stable_partition(uriResults_.begin(), uriResults_.end(),
FindURIResultByResult(r));
std::copy(uriResults_.begin(), i, std::back_inserter(res));
uriResults_.erase(uriResults_.begin(), i);
2009-06-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Removed _uris from RequestGroup. All functions that refer to _uris were moved to FileEntry. Exit status code are now defined in DownloadResultCode.h. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/AdaptiveURISelector.h * src/AutoSaveCommand.cc * src/BtPostDownloadHandler.cc * src/CheckIntegrityDispatcherCommand.cc * src/CookieStorage.cc * src/DHTAutoSaveCommand.cc * src/DHTBucketRefreshCommand.cc * src/DHTEntryPointNameResolveCommand.cc * src/DHTInteractionCommand.cc * src/DHTPeerAnnounceCommand.cc * src/DHTTokenUpdateCommand.cc * src/DlAbortEx.h * src/DlRetryEx.h * src/DownloadCommand.cc * src/DownloadContext.h * src/DownloadFailureException.h * src/DownloadResult.h * src/DownloadResultCode.h * src/FeedbackURISelector.cc * src/FeedbackURISelector.h * src/FileEntry.cc * src/FileEntry.h * src/FtpNegotiationCommand.cc * src/HttpListenCommand.cc * src/HttpResponseCommand.cc * src/HttpServerResponseCommand.cc * src/HttpSkipResponseCommand.cc * src/InOrderURISelector.cc * src/InOrderURISelector.h * src/Makefile.am * src/Makefile.in * src/Metalink2RequestGroup.cc * src/MultiUrlRequestInfo.cc * src/MultiUrlRequestInfo.h * src/OptionHandlerFactory.cc * src/PeerListenCommand.cc * src/RecoverableException.h * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/TimedHaltCommand.cc * src/TrackerWatcherCommand.cc * src/URIResult.cc * src/URIResult.h * src/URISelector.h * src/XmlRpcMethodImpl.cc * src/bittorrent_helper.cc * src/bittorrent_helper.h * src/download_helper.cc * src/main.cc * src/option_processing.cc * test/BtDependencyTest.cc * test/BtPostDownloadHandlerTest.cc * test/CookieStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DownloadHandlerFactoryTest.cc * test/DownloadHelperTest.cc * test/FeedbackURISelectorTest.cc * test/FileEntryTest.cc * test/InOrderURISelectorTest.cc * test/Metalink2RequestGroupTest.cc * test/MetalinkPostDownloadHandlerTest.cc * test/RequestGroupManTest.cc * test/RequestGroupTest.cc * test/XmlRpcMethodTest.cc
2009-06-29 08:42:58 +00:00
}
void FileEntry::reuseUri(const std::vector<std::string>& ignore)
{
if(logger_->debug()) {
for(std::vector<std::string>::const_iterator i = ignore.begin(),
eoi = ignore.end(); i != eoi; ++i) {
logger_->debug("ignore host=%s", (*i).c_str());
}
}
std::deque<std::string> uris = spentUris_;
std::sort(uris.begin(), uris.end());
uris.erase(std::unique(uris.begin(), uris.end()), uris.end());
std::vector<std::string> errorUris(uriResults_.size());
std::transform(uriResults_.begin(), uriResults_.end(),
errorUris.begin(), std::mem_fun_ref(&URIResult::getURI));
std::sort(errorUris.begin(), errorUris.end());
errorUris.erase(std::unique(errorUris.begin(), errorUris.end()),
errorUris.end());
if(logger_->debug()) {
for(std::vector<std::string>::const_iterator i = errorUris.begin(),
eoi = errorUris.end(); i != eoi; ++i) {
logger_->debug("error URI=%s", (*i).c_str());
}
}
std::vector<std::string> reusableURIs;
std::set_difference(uris.begin(), uris.end(),
errorUris.begin(), errorUris.end(),
std::back_inserter(reusableURIs));
std::vector<std::string>::iterator insertionPoint = reusableURIs.begin();
Request req;
for(std::vector<std::string>::iterator i = reusableURIs.begin(),
eoi = reusableURIs.end(); i != eoi; ++i) {
req.setUri(*i);
if(std::find(ignore.begin(), ignore.end(), req.getHost()) == ignore.end()) {
if(i != insertionPoint) {
*insertionPoint = *i;
}
++insertionPoint;
}
}
reusableURIs.erase(insertionPoint, reusableURIs.end());
size_t ininum = reusableURIs.size();
if(logger_->debug()) {
logger_->debug("Found %u reusable URIs", static_cast<unsigned int>(ininum));
for(std::vector<std::string>::const_iterator i = reusableURIs.begin(),
eoi = reusableURIs.end(); i != eoi; ++i) {
logger_->debug("URI=%s", (*i).c_str());
}
2010-02-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Wrapped logger->debug(...) with if(logger->debug()) { ... } * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/BtPieceMessage.cc * src/BtPortMessage.cc * src/CreateRequestCommand.cc * src/DHTAbstractNodeLookupTask.cc * src/DHTBucket.cc * src/DHTGetPeersCommand.cc * src/DHTMessageDispatcherImpl.cc * src/DHTMessageFactoryImpl.cc * src/DHTMessageTracker.cc * src/DHTPeerAnnounceStorage.cc * src/DHTRoutingTable.cc * src/DHTSetup.cc * src/DefaultBtAnnounce.cc * src/DefaultBtInteractive.cc * src/DefaultBtMessageDispatcher.cc * src/DefaultBtMessageReceiver.cc * src/DefaultBtProgressInfoFile.cc * src/DefaultBtRequestFactory.cc * src/DefaultPeerStorage.cc * src/DefaultPieceStorage.cc * src/DownloadCommand.cc * src/DownloadEngine.cc * src/EpollEventPoll.cc * src/FileAllocationCommand.cc * src/FileEntry.cc * src/FtpNegotiationCommand.cc * src/HandshakeExtensionMessage.cc * src/HttpListenCommand.cc * src/HttpServer.cc * src/HttpSkipResponseCommand.cc * src/IteratableChunkChecksumValidator.cc * src/Logger.h * src/MSEHandshake.cc * src/MetalinkPostDownloadHandler.cc * src/MultiDiskAdaptor.cc * src/PeerAbstractCommand.cc * src/PeerConnection.cc * src/PeerListenCommand.cc * src/PeerReceiveHandshakeCommand.cc * src/RequestGroup.cc * src/RequestGroupMan.cc * src/SegmentMan.cc * src/SelectEventPoll.cc * src/ServerStat.cc * src/SimpleBtMessage.cc * src/SocketCore.cc * src/TrackerWatcherCommand.cc * src/UTMetadataDataExtensionMessage.cc * src/UTMetadataRequestFactory.cc * src/UTMetadataRequestTracker.cc * src/XmlRpcMethod.cc
2010-02-09 12:20:20 +00:00
}
uris_.insert(uris_.end(), reusableURIs.begin(), reusableURIs.end());
}
void FileEntry::releaseRuntimeResource()
{
requestPool_.clear();
inFlightRequests_.clear();
}
template<typename InputIterator, typename T>
static InputIterator findRequestByUri
(InputIterator first, InputIterator last, const T& uri)
{
for(; first != last; ++first) {
if(!(*first)->removalRequested() && (*first)->getUri() == uri) {
return first;
}
}
return last;
}
bool FileEntry::removeUri(const std::string& uri)
{
std::deque<std::string>::iterator itr =
std::find(spentUris_.begin(), spentUris_.end(), uri);
if(itr == spentUris_.end()) {
itr = std::find(uris_.begin(), uris_.end(), uri);
if(itr == uris_.end()) {
return false;
} else {
uris_.erase(itr);
return true;
}
} else {
spentUris_.erase(itr);
SharedHandle<Request> req;
std::deque<SharedHandle<Request> >::iterator riter =
findRequestByUri(inFlightRequests_.begin(), inFlightRequests_.end(), uri);
if(riter == inFlightRequests_.end()) {
riter = findRequestByUri(requestPool_.begin(), requestPool_.end(), uri);
if(riter == requestPool_.end()) {
return true;
} else {
req = *riter;
requestPool_.erase(riter);
}
} else {
req = *riter;
}
req->requestRemoval();
return true;
}
}
std::string FileEntry::getBasename() const
{
return File(path_).getBasename();
}
std::string FileEntry::getDirname() const
{
return File(path_).getDirname();
}
size_t FileEntry::setUris(const std::vector<std::string>& uris)
{
uris_.clear();
return addUris(uris.begin(), uris.end());
}
bool FileEntry::addUri(const std::string& uri)
{
if(Request().setUri(uri)) {
uris_.push_back(uri);
return true;
} else {
return false;
}
}
bool FileEntry::insertUri(const std::string& uri, size_t pos)
{
if(Request().setUri(uri)) {
pos = std::min(pos, uris_.size());
uris_.insert(uris_.begin()+pos, uri);
return true;
} else {
return false;
}
}
} // namespace aria2