Class DownloadManagerImpl
- java.lang.Object
-
- com.biglybt.core.logging.LogRelation
-
- com.biglybt.core.download.impl.DownloadManagerImpl
-
- All Implemented Interfaces:
DiskManagerUtil.MoveTaskAapter
,DownloadManager
,Taggable
,DataSourceResolver.ExportableDataSource
,Taggable
public class DownloadManagerImpl extends LogRelation implements DownloadManager, Taggable, DataSourceResolver.ExportableDataSource, DiskManagerUtil.MoveTaskAapter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DownloadManagerImpl.NoStackException
-
Field Summary
-
Fields inherited from interface com.biglybt.core.download.DownloadManager
EF_WAS_FORCE_START, ET_FILE_MISSING, ET_INSUFFICIENT_SPACE, ET_NONE, ET_OTHER, ET_STOP_DURING_INIT, STATE_ALLOCATING, STATE_CHECKING, STATE_CLOSED, STATE_DOWNLOADING, STATE_ERROR, STATE_FINISHING, STATE_INITIALIZED, STATE_INITIALIZING, STATE_QUEUED, STATE_READY, STATE_SEEDING, STATE_START_OF_DAY, STATE_STOPPED, STATE_STOPPING, STATE_WAITING, UD_KEY_STOP_REASON, WEALTH_ERROR, WEALTH_KO, WEALTH_NO_REMOTE, WEALTH_NO_TRACKER, WEALTH_OK, WEALTH_STOPPED
-
Fields inherited from interface com.biglybt.core.tag.Taggable
TT_DOWNLOAD, TT_PEER
-
-
Constructor Summary
Constructors Constructor Description DownloadManagerImpl(GlobalManager _gm, byte[] _torrent_hash, java.lang.String _torrentFileName, java.lang.String _torrent_save_dir, java.lang.String _torrent_save_file, int _initialState, boolean _persistent, boolean _recovered, boolean _open_for_seeding, boolean _has_ever_been_started, java.util.List _file_priorities, DownloadManagerInitialisationAdapter _initialisation_adapter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected boolean
activateRequest(int count)
void
addActivationListener(DownloadManagerActivationListener listener)
void
addDiskListener(DownloadManagerDiskListener listener)
static void
addGlobalDownloadListener(DownloadManagerListener listener)
void
addListener(DownloadManagerListener listener)
void
addListener(DownloadManagerListener listener, boolean triggerStateChange)
void
addPeer(PEPeer peer)
void
addPeerListener(DownloadManagerPeerListener listener)
void
addPeerListener(DownloadManagerPeerListener listener, boolean bDispatchForExisting)
void
addPiece(PEPiece piece)
void
addPieceListener(DownloadManagerPieceListener listener)
void
addPieceListener(DownloadManagerPieceListener listener, boolean bDispatchForExisting)
void
addRateLimiter(LimitedRateGroup group, boolean upload)
void
addTPSListener(DownloadManagerTPSListener listener)
void
addTrackerListener(DownloadManagerTrackerListener listener)
private void
buildURLGroupMap(TOTorrent torrent)
boolean
canExportDownload()
boolean
canForceRecheck()
boolean
canMoveDataFiles()
void
checkLightSeeding(boolean full_sync)
private void
checkResuming()
protected void
clearFileLinks()
void
copyDataFiles(java.io.File dest_parent_dir)
private void
copyTorrentFile(java.io.File parent_dir)
protected void
deleteDataFiles()
protected void
deletePartialDataFiles()
protected void
deleteTorrentFile()
void
destroy(boolean is_duplicate)
Indicates that the download manager is no longer neededprotected void
downloadEnded(boolean never_downloaded)
Is called when a download is finished.boolean
equals(java.lang.Object obj)
DataSourceResolver.ExportedDataSource
exportDataSource()
void
exportDownload(java.io.File parent_dir)
boolean
filesExist(boolean expected_to_be_allocated)
Checks if all the files the user wants to download from this torrent actually exist on their filesystem.void
fireGlobalManagerEvent(int eventType)
void
forceRecheck()
void
forceRecheck(ForceRecheckListener l)
void
generateEvidence(IndentWriter writer)
java.io.File
getAbsoluteSaveLocation()
Returns the file location where we save the torrent, this includes the parent directory and the actual file name.int
getActivationCount()
protected java.lang.Object[]
getActiveScrapeResponse()
Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapesboolean
getAssumedComplete()
Retrieve whether this download is assumed complete.long
getAutoResumeTime()
long
getCreationTime()
gives the time this download was created (not the torrent but the download itself)int
getCryptoLevel()
PEPeer[]
getCurrentPeers()
PEPiece[]
getCurrentPieces()
DiskManager
getDiskManager()
DiskManagerFileInfo[]
getDiskManagerFileInfo()
Deprecated.use getDiskManagerFileInfoSet() insteadDiskManagerFileInfoSet
getDiskManagerFileInfoSet()
DiskManagerPiece[]
getDiskManagerPiecesSnapshot()
java.lang.String
getDisplayName()
DownloadManagerState
getDownloadState()
int
getEffectiveMaxUploads()
Returns the max uploads depending on whether the download is seeding and it has a separate rate for thisprotected int
getEffectiveUploadPriority()
int
getEffectiveUploadRateLimitBytesPerSecond()
returns the currently in force upload speed limit which may vary from the stats.java.lang.String
getErrorDetails()
int
getErrorFlags()
int
getErrorType()
int
getExtendedMessagingMode()
GlobalManager
getGlobalManager()
java.util.List<TRTrackerScraperResponse>
getGoodTrackerScrapeResponses()
int
getHealthStatus()
private byte[]
getIdentity()
java.lang.String
getInternalName()
returns a name based on the torrent hash or an empty string if torrent invalidprivate int
getLightSeedTrackerStatus(java.lang.String name)
protected int[]
getMaxConnections(boolean mixed)
protected int[]
getMaxConnectionsWhenSeeding(boolean mixed)
protected int[]
getMaxSeedConnections(boolean mixed)
int
getMaxUploads()
protected int
getMaxUploadsWhenSeeding()
long[]
getMoveProgress()
Progress of a move operationjava.lang.String
getMoveSubTask()
java.lang.Object[]
getNATStatus()
See plugin ConnectionManager.NAT_ constants for return valuesint
getNbPeers()
int
getNbPieces()
int
getNbSeeds()
int
getNumFileInfos()
PEPeerManager
getPeerManager()
java.lang.String
getPieceLength()
int
getPosition()
java.lang.Object[]
getQueryableInterfaces()
Query this class for a reference to another class that it may holdLimitedRateGroup[]
getRateLimiters(boolean upload)
java.lang.String
getRelationText()
A short description of what your class holds that can be printed by the loggerjava.io.File
getSaveLocation()
Download.SeedingRank
getSeedingRank()
long
getSize()
int
getState()
DownloadManagerStats
getStats()
java.lang.String
getStopReason()
int[]
getStorageType(DiskManagerFileInfo[] info)
int
getSubState()
For stopping this returns the target state after stopping (stopped/queued)java.lang.String
getSwarmMergingInfo()
java.lang.String
getTaggableID()
java.lang.String
getTaggableName()
TaggableResolver
getTaggableResolver()
java.lang.Object
getTaggableTransientProperty(java.lang.String key)
int
getTaggableType()
int
getTCPListeningPortNumber()
protected int
getTCPPortOverride(boolean only_if_allocated)
TOTorrent
getTorrent()
java.lang.String
getTorrentComment()
java.lang.String
getTorrentCreatedBy()
long
getTorrentCreationDate()
java.lang.String
getTorrentFileName()
This includes the full path to the torrent file.protected HashWrapper
getTorrentHashOverride()
TRTrackerAnnouncer
getTrackerClient()
java.util.List<TrackerPeerSource>
getTrackerPeerSources()
TRTrackerScraperResponse
getTrackerScrapeResponse()
java.lang.String
getTrackerStatus()
int
getTrackerTime()
When the next call to the tracker will occur (in seconds)protected int
getTrackerURLGroup(java.lang.String key)
java.lang.Object
getUserData(java.lang.Object key)
To retreive arbitrary objects against a download.int
hashCode()
protected void
informDownloadEnded()
protected void
informLocationChange(int file_index)
protected void
informLocationChange(DiskManagerFileInfo file)
protected void
informPositionChanged(int new_position)
protected void
informPrioritiesChange(java.util.List files)
protected void
informPriorityChange(DiskManagerFileInfo file)
protected void
informStarted(PEPeerManager pm)
protected void
informStateChanged()
Doesn't not inform if state didn't change from last inform callprotected void
informStopped(PEPeerManager pm, boolean for_queue)
void
informTPSChanged()
protected void
informWillBeStarted(PEPeerManager pm)
void
initialize()
boolean
isConstructed()
boolean
isDataAlreadyAllocated()
Determine whether disk allocation has already been done.boolean
isDestroyed()
boolean
isDownloadComplete(boolean bIncludeDND)
Retrieves whether the download is completeboolean
isForceRechecking()
boolean
isForceStart()
boolean
isInDefaultSaveDir()
Returns true if the download is being saved to one of the default save directories.protected boolean
isLightSeedTracker(java.net.InetSocketAddress isa)
protected boolean
isMaxConnectionsWhenSeedingEnabled()
protected boolean
isMaxUploadsWhenSeedingEnabled()
boolean
isPaused()
boolean
isPersistent()
boolean
isSwarmMerging()
boolean
isTrackerError()
boolean
isUnauthorisedOnTracker()
void
moveDataFiles(java.io.File new_parent_dir)
Move data files to new location.void
moveDataFiles(java.io.File destination, java.lang.String new_name)
Move the files and rename a download in one go.void
moveDataFiles(java.io.File destination, java.lang.String new_name, boolean live)
void
moveDataFilesLive(java.io.File new_parent_dir)
At some point someone made the file-move operations stop+restart the download when it was designed to work without doing this (see move-on-complete for example).(package private) void
moveDataFilesSupport(java.io.File new_parent_dir, java.lang.String new_filename)
(package private) void
moveDataFilesSupport0(java.io.File new_parent_dir, java.lang.String new_filename)
void
moveTorrentFile(java.io.File new_parent_dir)
Move torrent file to new location.void
moveTorrentFile(java.io.File new_parent_dir, java.lang.String new_name)
private void
moveTorrentFile0(java.io.File new_parent_dir, java.lang.String new_name)
boolean
pause(boolean only_if_active)
boolean
pause(boolean only_if_active, long _resume_time)
protected void
readParameters()
protected void
readTorrent()
private void
readTorrent(java.lang.String torrent_save_dir, java.lang.String torrent_save_file, byte[] torrent_hash, boolean new_torrent, boolean for_seeding, boolean has_ever_been_started, int initial_state)
void
recheckFile(DiskManagerFileInfo file)
Recheck a particular file.void
removeActivationListener(DownloadManagerActivationListener listener)
void
removeDiskListener(DownloadManagerDiskListener listener)
static void
removeGlobalDownloadListener(DownloadManagerListener listener)
void
removeListener(DownloadManagerListener listener)
void
removePeer(PEPeer peer)
void
removePeerListener(DownloadManagerPeerListener listener)
void
removePiece(PEPiece piece)
void
removePieceListener(DownloadManagerPieceListener listener)
void
removeRateLimiter(LimitedRateGroup group, boolean upload)
void
removeTPSListener(DownloadManagerTPSListener listener)
void
removeTrackerListener(DownloadManagerTrackerListener listener)
void
rename(java.lang.String name)
Renames the save file, torrent file and the displayed name.void
renameDownload(java.lang.String new_name)
Rename the download - this means the name of the file being downloaded (for single file torrents), or the name of the directory holding the files (in a multi-file torrent).void
renameTorrent(java.lang.String name)
void
renameTorrentSafe(java.lang.String name)
Same as renameTorrent, but appends numbers if torrent already existsvoid
requestAllocation(java.util.List<DiskManagerFileInfo> files)
Instructions that file given files need allocation - used when switching file storage types/skipped state Will pause and resume the download if it is activeboolean
requestAssumedCompleteMode()
Will set this download to be "assumed complete" for if the download is already complete (excluding DND)protected boolean
requestAssumedCompleteMode(boolean filePriorityChanged)
void
requestAttention()
void
requestTrackerAnnounce(boolean force)
void
requestTrackerScrape(boolean force)
void
resetFile(DiskManagerFileInfo file)
Reset the file download state to totally undownloaded.void
resume()
void
saveDownload(boolean interim)
persist any general download related information, excluding resume data which is managed separately by saveResumeDatavoid
saveResumeData()
persist resume databoolean
seedPieceRecheck()
Gives the download an opportunity to schedule seeding mode piece rechecks if desiredvoid
setAnnounceResult(DownloadAnnounceResult result)
protected void
setAssumedComplete(boolean _assumedComplete)
protected void
setAssumedComplete(boolean _assumedComplete, boolean filePriorityChanged)
void
setAutoResumeTime(long time)
void
setCreationTime(long t)
void
setCryptoLevel(int level)
void
setDataAlreadyAllocated(boolean already_allocated)
Set whether data allocation has already been done, so we know when to allocate and when to throw a missing-data error message.void
setErrorState(int errorType, java.lang.String errorDetails, int errorFlags)
Download must be stopped - used at start-of-day to recover error stateprotected void
setFailed(int error, java.lang.String str)
protected void
setFailed(java.lang.String str)
protected void
setFailed(java.lang.String str, java.lang.Throwable e)
protected void
setFileLinks()
void
setFilePriorities(DiskManagerFileInfo[] fileInfos, int priority)
Sets the priority for an array for filesvoid
setForceStart(boolean forceStart)
void
setManualUploadPriority(int priority)
void
setMaxUploads(int max)
void
setMoveState(int state)
void
setPieceCheckingEnabled(boolean enabled)
Use with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the testvoid
setPosition(int new_position)
void
setScrapeResult(DownloadScrapeResult result)
void
setSeedingRank(Download.SeedingRank rank)
void
setStateFinishing()
void
setStateQueued()
void
setStateWaiting()
void
setStopReason(java.lang.String reason)
void
setTaggableTransientProperty(java.lang.String key, java.lang.Object value)
void
setTorrentFile(java.io.File new_parent_dir, java.lang.String new_name)
Sets the torrent file name (will perform a move of the torrent file) - this shouldn't be used unless you know what you are doing (it requires the download to be stopped!) - it is safer to use moveTorrentFile instead.void
setTorrentFileName(java.lang.String string)
protected void
setTorrentInvalid(java.lang.Throwable cause)
void
setTorrentSaveDir(java.io.File _new_location, boolean locationIncludesName)
changes the save directory.protected void
setTrackerRefreshDelayOverrides(int percent)
void
setTrackerScrapeResponse(TRTrackerScraperResponse response)
void
setUserData(java.lang.Object key, java.lang.Object value)
To store arbitrary objects against a download.void
startDownload()
private void
startQueuedTrackerClient()
void
stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data)
Stop the download manager, and do any file/torrent removals.void
stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data, boolean for_removal)
As above but definitely indicates that the stop is for removal (if for_removal is true) and therefore that any removal specific actions such as removing partial files should be performedboolean
stopPausedDownload()
private void
stopQueuedTrackerClient()
java.lang.String
toString()
void
updateAutoUploadPriority(java.lang.Object key, boolean inc)
private void
updateFileLink(int file_index, java.io.File old_path, java.io.File new_path, java.io.File from_loc, java.io.File to_loc, java.util.List<java.lang.Integer> from_indexes, java.util.List<java.io.File> from_links, java.util.List<java.io.File> to_links)
private void
updateFileLinks(java.io.File old_save_path, java.io.File new_save_path)
-
Methods inherited from class com.biglybt.core.logging.LogRelation
propogatedRelationText, queryForClass
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.biglybt.core.download.DownloadManager
setTorrentSaveDir
-
-
-
-
Field Detail
-
SCRAPE_DELAY_ERROR_TORRENTS
private static final long SCRAPE_DELAY_ERROR_TORRENTS
- See Also:
- Constant Field Values
-
SCRAPE_DELAY_STOPPED_TORRENTS
private static final long SCRAPE_DELAY_STOPPED_TORRENTS
- See Also:
- Constant Field Values
-
SCRAPE_INITDELAY_ERROR_TORRENTS
private static final long SCRAPE_INITDELAY_ERROR_TORRENTS
- See Also:
- Constant Field Values
-
SCRAPE_INITDELAY_STOPPED_TORRENTS
private static final long SCRAPE_INITDELAY_STOPPED_TORRENTS
- See Also:
- Constant Field Values
-
upload_when_busy_min_secs
private static int upload_when_busy_min_secs
-
max_connections_npp_extra
private static int max_connections_npp_extra
-
default_light_seeding_status
private static int default_light_seeding_status
-
client_id_manager
private static final ClientIDManagerImpl client_id_manager
-
CFG_MOVE_COMPLETED_TOP
private static final java.lang.String CFG_MOVE_COMPLETED_TOP
- See Also:
- Constant Field Values
-
LDT_STATECHANGED
private static final int LDT_STATECHANGED
- See Also:
- Constant Field Values
-
LDT_DOWNLOADCOMPLETE
private static final int LDT_DOWNLOADCOMPLETE
- See Also:
- Constant Field Values
-
LDT_COMPLETIONCHANGED
private static final int LDT_COMPLETIONCHANGED
- See Also:
- Constant Field Values
-
LDT_POSITIONCHANGED
private static final int LDT_POSITIONCHANGED
- See Also:
- Constant Field Values
-
LDT_FILEPRIORITYCHANGED
private static final int LDT_FILEPRIORITYCHANGED
- See Also:
- Constant Field Values
-
LDT_FILELOCATIONCHANGED
private static final int LDT_FILELOCATIONCHANGED
- See Also:
- Constant Field Values
-
port_init_lock
private static java.lang.Object port_init_lock
-
listeners_mon
private final AEMonitor listeners_mon
-
listeners_aggregator
static final ListenerManager<DownloadManagerListener> listeners_aggregator
-
global_dm_listeners
static final CopyOnWriteList<DownloadManagerListener> global_dm_listeners
-
global_dm_listener
private static final DownloadManagerListener global_dm_listener
-
defaultSeedingRank
private static final Download.SeedingRank defaultSeedingRank
-
all_trackers
private static final AllTrackersManager.AllTrackers all_trackers
-
listeners
private final ListenerManager<DownloadManagerListener> listeners
-
LDT_TL_ANNOUNCERESULT
private static final int LDT_TL_ANNOUNCERESULT
- See Also:
- Constant Field Values
-
LDT_TL_SCRAPERESULT
private static final int LDT_TL_SCRAPERESULT
- See Also:
- Constant Field Values
-
tracker_listeners
final ListenerManager<DownloadManagerTrackerListener> tracker_listeners
-
LDT_PE_PEER_ADDED
private static final int LDT_PE_PEER_ADDED
- See Also:
- Constant Field Values
-
LDT_PE_PEER_REMOVED
private static final int LDT_PE_PEER_REMOVED
- See Also:
- Constant Field Values
-
LDT_PE_PM_ADDED
private static final int LDT_PE_PM_ADDED
- See Also:
- Constant Field Values
-
LDT_PE_PM_REMOVED
private static final int LDT_PE_PM_REMOVED
- See Also:
- Constant Field Values
-
peer_listeners_aggregator
static final ListenerManager<DownloadManagerPeerListener> peer_listeners_aggregator
-
TPS_Key
static final java.lang.Object TPS_Key
-
dnd_subfolder
public static volatile java.lang.String dnd_subfolder
-
save_dir_check_cache
private static java.util.Map<java.lang.String,java.lang.Boolean> save_dir_check_cache
-
save_dir_check_timer
private static TimerEventPeriodic save_dir_check_timer
-
peer_listeners
private final ListenerManager<DownloadManagerPeerListener> peer_listeners
-
peer_listeners_mon
final AEMonitor peer_listeners_mon
-
current_peers
final java.util.Map<PEPeer,java.lang.String> current_peers
-
current_peers_unmatched_removal
private final java.util.Map<PEPeer,java.lang.Long> current_peers_unmatched_removal
-
LDT_PE_PIECE_ADDED
private static final int LDT_PE_PIECE_ADDED
- See Also:
- Constant Field Values
-
LDT_PE_PIECE_REMOVED
private static final int LDT_PE_PIECE_REMOVED
- See Also:
- Constant Field Values
-
piece_listeners_aggregator
static final ListenerManager<DownloadManagerPieceListener> piece_listeners_aggregator
-
piece_listeners
private final ListenerManager<DownloadManagerPieceListener> piece_listeners
-
constructed
private boolean constructed
-
init_lock
private java.lang.Object init_lock
-
initialised
private boolean initialised
-
post_init_tasks
private java.util.List<java.lang.Runnable> post_init_tasks
-
tps_listeners
private java.util.List<DownloadManagerTPSListener> tps_listeners
-
piece_listeners_mon
private final AEMonitor piece_listeners_mon
-
current_pieces
private final java.util.List<PEPiece> current_pieces
-
controller
final DownloadManagerController controller
-
stats
private final DownloadManagerStatsImpl stats
-
this_mon
protected final AEMonitor this_mon
-
persistent
private final boolean persistent
-
assumedComplete
private volatile boolean assumedComplete
Pretend this download is complete while not running, even if it has no data. When the torrent starts up, the real complete level will be checked (probably by DiskManager), and if the torrent actually does have missing data at that point, the download will be thrown into error state.Only a forced-recheck should clear this flag.
Current Implementation:
- implies that the user completed the download at one point
- Checks if there's Data Missing when torrent is done (or torrent load)
-
last_informed_state
private int last_informed_state
forceStarted torrents can't/shouldn't be automatically stopped
-
latest_informed_force_start
private boolean latest_informed_force_start
-
resume_time
private long resume_time
-
globalManager
final GlobalManager globalManager
-
torrentFileName
private java.lang.String torrentFileName
-
torrentFileExplicitlyDeleted
private boolean torrentFileExplicitlyDeleted
-
open_for_seeding
private boolean open_for_seeding
-
display_name
private java.lang.String display_name
-
internal_name
private java.lang.String internal_name
-
torrent_save_location
private java.io.File torrent_save_location
-
position
private int position
-
read_torrent_state
private java.lang.Object[] read_torrent_state
-
download_manager_state
DownloadManagerState download_manager_state
-
torrent
private TOTorrent torrent
-
torrent_comment
private java.lang.String torrent_comment
-
torrent_created_by
private java.lang.String torrent_created_by
-
url_group_map
private volatile java.util.Map<java.lang.String,java.lang.Object[]> url_group_map
-
url_group_map_uid
private volatile long url_group_map_uid
-
_tracker_client
private volatile TRTrackerAnnouncer _tracker_client
-
_tracker_client_for_queued_download
private volatile TRTrackerAnnouncer _tracker_client_for_queued_download
-
light_seeding_status
private volatile int light_seeding_status
-
tracker_client_listener
private final TRTrackerAnnouncerListener tracker_client_listener
-
tracker_client_stats_listener
private final TRTrackerAnnouncerListener tracker_client_stats_listener
-
activation_listeners
private final CopyOnWriteList<DownloadManagerActivationListener> activation_listeners
-
scrape_random_seed
private final long scrape_random_seed
-
data
private volatile java.util.Map<java.lang.Object,java.lang.Object> data
-
data_already_allocated
private boolean data_already_allocated
-
creation_time
private long creation_time
-
seedingRank
private Download.SeedingRank seedingRank
-
dl_identity_obtained
private boolean dl_identity_obtained
-
dl_identity
private byte[] dl_identity
-
dl_identity_hashcode
private int dl_identity_hashcode
-
max_uploads
private int max_uploads
-
max_connections
private int max_connections
-
max_connections_when_seeding
private int max_connections_when_seeding
-
max_connections_when_seeding_enabled
private boolean max_connections_when_seeding_enabled
-
max_seed_connections
private int max_seed_connections
-
max_uploads_when_seeding
private int max_uploads_when_seeding
-
max_uploads_when_seeding_enabled
private boolean max_uploads_when_seeding_enabled
-
max_upload_when_busy_bps
private int max_upload_when_busy_bps
-
current_upload_when_busy_bps
private int current_upload_when_busy_bps
-
last_upload_when_busy_update
private long last_upload_when_busy_update
-
last_upload_when_busy_dec_time
private long last_upload_when_busy_dec_time
-
upload_priority_manual
private int upload_priority_manual
-
upload_priority_auto
private int upload_priority_auto
-
crypto_level
private int crypto_level
-
message_mode
private int message_mode
-
tcp_port_override
private volatile int tcp_port_override
-
removing
private volatile boolean removing
-
destroyed
private volatile boolean destroyed
-
cached_save_location
private java.io.File cached_save_location
-
cached_save_location_result
private java.io.File cached_save_location_result
-
TTP_KEY
private static java.lang.Object TTP_KEY
-
move_progress
private volatile long[] move_progress
-
move_subtask
private volatile java.lang.String move_subtask
-
move_state
private volatile int move_state
-
-
Constructor Detail
-
DownloadManagerImpl
public DownloadManagerImpl(GlobalManager _gm, byte[] _torrent_hash, java.lang.String _torrentFileName, java.lang.String _torrent_save_dir, java.lang.String _torrent_save_file, int _initialState, boolean _persistent, boolean _recovered, boolean _open_for_seeding, boolean _has_ever_been_started, java.util.List _file_priorities, DownloadManagerInitialisationAdapter _initialisation_adapter)
-
-
Method Detail
-
addGlobalDownloadListener
public static void addGlobalDownloadListener(DownloadManagerListener listener)
-
removeGlobalDownloadListener
public static void removeGlobalDownloadListener(DownloadManagerListener listener)
-
isConstructed
public boolean isConstructed()
- Specified by:
isConstructed
in interfaceDownloadManager
-
buildURLGroupMap
private void buildURLGroupMap(TOTorrent torrent)
-
getLightSeedTrackerStatus
private int getLightSeedTrackerStatus(java.lang.String name)
-
getTrackerURLGroup
protected int getTrackerURLGroup(java.lang.String key)
-
getTaggableType
public int getTaggableType()
- Specified by:
getTaggableType
in interfaceTaggable
-
getTaggableResolver
public TaggableResolver getTaggableResolver()
- Specified by:
getTaggableResolver
in interfaceTaggable
-
getTaggableID
public java.lang.String getTaggableID()
- Specified by:
getTaggableID
in interfaceTaggable
-
getTaggableName
public java.lang.String getTaggableName()
- Specified by:
getTaggableName
in interfaceTaggable
-
exportDataSource
public DataSourceResolver.ExportedDataSource exportDataSource()
- Specified by:
exportDataSource
in interfaceDataSourceResolver.ExportableDataSource
-
readTorrent
private void readTorrent(java.lang.String torrent_save_dir, java.lang.String torrent_save_file, byte[] torrent_hash, boolean new_torrent, boolean for_seeding, boolean has_ever_been_started, int initial_state)
-
readTorrent
protected void readTorrent()
-
readParameters
protected void readParameters()
-
getMaxConnections
protected int[] getMaxConnections(boolean mixed)
-
getMaxConnectionsWhenSeeding
protected int[] getMaxConnectionsWhenSeeding(boolean mixed)
-
isMaxConnectionsWhenSeedingEnabled
protected boolean isMaxConnectionsWhenSeedingEnabled()
-
getMaxSeedConnections
protected int[] getMaxSeedConnections(boolean mixed)
-
isMaxUploadsWhenSeedingEnabled
protected boolean isMaxUploadsWhenSeedingEnabled()
-
getMaxUploadsWhenSeeding
protected int getMaxUploadsWhenSeeding()
-
updateAutoUploadPriority
public void updateAutoUploadPriority(java.lang.Object key, boolean inc)
- Specified by:
updateAutoUploadPriority
in interfaceDownloadManager
-
getEffectiveUploadPriority
protected int getEffectiveUploadPriority()
-
getMaxUploads
public int getMaxUploads()
- Specified by:
getMaxUploads
in interfaceDownloadManager
-
setMaxUploads
public void setMaxUploads(int max)
- Specified by:
setMaxUploads
in interfaceDownloadManager
-
setManualUploadPriority
public void setManualUploadPriority(int priority)
-
getEffectiveMaxUploads
public int getEffectiveMaxUploads()
Description copied from interface:DownloadManager
Returns the max uploads depending on whether the download is seeding and it has a separate rate for this- Specified by:
getEffectiveMaxUploads
in interfaceDownloadManager
- Returns:
-
getEffectiveUploadRateLimitBytesPerSecond
public int getEffectiveUploadRateLimitBytesPerSecond()
Description copied from interface:DownloadManager
returns the currently in force upload speed limit which may vary from the stats. value as this gives the fixed per-torrent limit- Specified by:
getEffectiveUploadRateLimitBytesPerSecond
in interfaceDownloadManager
- Returns:
-
setFileLinks
protected void setFileLinks()
-
clearFileLinks
protected void clearFileLinks()
-
updateFileLinks
private void updateFileLinks(java.io.File old_save_path, java.io.File new_save_path)
-
updateFileLink
private void updateFileLink(int file_index, java.io.File old_path, java.io.File new_path, java.io.File from_loc, java.io.File to_loc, java.util.List<java.lang.Integer> from_indexes, java.util.List<java.io.File> from_links, java.util.List<java.io.File> to_links)
-
filesExist
public boolean filesExist(boolean expected_to_be_allocated)
Description copied from interface:DownloadManager
Checks if all the files the user wants to download from this torrent actually exist on their filesystem.If a file does not exist, the download will be set to error state.
- Specified by:
filesExist
in interfaceDownloadManager
- Parameters:
expected_to_be_allocated
- if this is false and allocation hasn't been attempted then the method will return with false without marking the download as in an error state- Returns:
- Whether all the non-skipped (non-DND) files exist
-
isPersistent
public boolean isPersistent()
- Specified by:
isPersistent
in interfaceDownloadManager
-
getDisplayName
public java.lang.String getDisplayName()
- Specified by:
getDisplayName
in interfaceDownloadManager
-
getInternalName
public java.lang.String getInternalName()
Description copied from interface:DownloadManager
returns a name based on the torrent hash or an empty string if torrent invalid- Specified by:
getInternalName
in interfaceDownloadManager
- Returns:
-
setErrorState
public void setErrorState(int errorType, java.lang.String errorDetails, int errorFlags)
Description copied from interface:DownloadManager
Download must be stopped - used at start-of-day to recover error state- Specified by:
setErrorState
in interfaceDownloadManager
-
getErrorDetails
public java.lang.String getErrorDetails()
- Specified by:
getErrorDetails
in interfaceDownloadManager
-
getErrorType
public int getErrorType()
- Specified by:
getErrorType
in interfaceDownloadManager
-
getErrorFlags
public int getErrorFlags()
- Specified by:
getErrorFlags
in interfaceDownloadManager
-
getSize
public long getSize()
- Specified by:
getSize
in interfaceDownloadManager
-
setFailed
protected void setFailed(java.lang.String str)
-
setFailed
protected void setFailed(int error, java.lang.String str)
-
setFailed
protected void setFailed(java.lang.String str, java.lang.Throwable e)
-
setTorrentInvalid
protected void setTorrentInvalid(java.lang.Throwable cause)
-
getTCPPortOverride
protected int getTCPPortOverride(boolean only_if_allocated)
-
getTorrentHashOverride
protected HashWrapper getTorrentHashOverride()
-
getTCPListeningPortNumber
public int getTCPListeningPortNumber()
- Specified by:
getTCPListeningPortNumber
in interfaceDownloadManager
-
saveResumeData
public void saveResumeData()
Description copied from interface:DownloadManager
persist resume data- Specified by:
saveResumeData
in interfaceDownloadManager
-
saveDownload
public void saveDownload(boolean interim)
Description copied from interface:DownloadManager
persist any general download related information, excluding resume data which is managed separately by saveResumeData- Specified by:
saveDownload
in interfaceDownloadManager
-
initialize
public void initialize()
- Specified by:
initialize
in interfaceDownloadManager
-
checkLightSeeding
public void checkLightSeeding(boolean full_sync)
- Specified by:
checkLightSeeding
in interfaceDownloadManager
-
isLightSeedTracker
protected boolean isLightSeedTracker(java.net.InetSocketAddress isa)
-
startQueuedTrackerClient
private void startQueuedTrackerClient()
-
stopQueuedTrackerClient
private void stopQueuedTrackerClient()
-
setStateWaiting
public void setStateWaiting()
- Specified by:
setStateWaiting
in interfaceDownloadManager
-
setStateFinishing
public void setStateFinishing()
-
setStateQueued
public void setStateQueued()
- Specified by:
setStateQueued
in interfaceDownloadManager
-
getState
public int getState()
- Specified by:
getState
in interfaceDownloadManager
-
getSubState
public int getSubState()
Description copied from interface:DownloadManager
For stopping this returns the target state after stopping (stopped/queued)- Specified by:
getSubState
in interfaceDownloadManager
- Returns:
-
canForceRecheck
public boolean canForceRecheck()
- Specified by:
canForceRecheck
in interfaceDownloadManager
-
forceRecheck
public void forceRecheck()
- Specified by:
forceRecheck
in interfaceDownloadManager
-
forceRecheck
public void forceRecheck(ForceRecheckListener l)
- Specified by:
forceRecheck
in interfaceDownloadManager
-
isForceRechecking
public boolean isForceRechecking()
- Specified by:
isForceRechecking
in interfaceDownloadManager
-
setPieceCheckingEnabled
public void setPieceCheckingEnabled(boolean enabled)
Description copied from interface:DownloadManager
Use with care - introduced to support speed tests whereby we want to avoid checking the virtual torrent used for the test- Specified by:
setPieceCheckingEnabled
in interfaceDownloadManager
-
resetFile
public void resetFile(DiskManagerFileInfo file)
Description copied from interface:DownloadManager
Reset the file download state to totally undownloaded. Download must be stopped- Specified by:
resetFile
in interfaceDownloadManager
-
recheckFile
public void recheckFile(DiskManagerFileInfo file)
Description copied from interface:DownloadManager
Recheck a particular file. Download must be stopped- Specified by:
recheckFile
in interfaceDownloadManager
-
requestAllocation
public void requestAllocation(java.util.List<DiskManagerFileInfo> files)
Description copied from interface:DownloadManager
Instructions that file given files need allocation - used when switching file storage types/skipped state Will pause and resume the download if it is active- Specified by:
requestAllocation
in interfaceDownloadManager
-
startDownload
public void startDownload()
- Specified by:
startDownload
in interfaceDownloadManager
-
stopIt
public void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data)
Description copied from interface:DownloadManager
Stop the download manager, and do any file/torrent removals.- Specified by:
stopIt
in interfaceDownloadManager
remove_torrent
- remove the .torrent file after stoppingremove_data
- remove the data file after stopping
-
setStopReason
public void setStopReason(java.lang.String reason)
- Specified by:
setStopReason
in interfaceDownloadManager
-
getStopReason
public java.lang.String getStopReason()
- Specified by:
getStopReason
in interfaceDownloadManager
-
stopIt
public void stopIt(int state_after_stopping, boolean remove_torrent, boolean remove_data, boolean for_removal)
Description copied from interface:DownloadManager
As above but definitely indicates that the stop is for removal (if for_removal is true) and therefore that any removal specific actions such as removing partial files should be performed- Specified by:
stopIt
in interfaceDownloadManager
-
checkResuming
private void checkResuming()
-
pause
public boolean pause(boolean only_if_active)
- Specified by:
pause
in interfaceDownloadManager
- Returns:
- true -> download was placed into a paused state (including if it was already paused)
-
pause
public boolean pause(boolean only_if_active, long _resume_time)
- Specified by:
pause
in interfaceDownloadManager
- Returns:
- true -> download was placed into a paused state (including if it was already paused)
-
getAutoResumeTime
public long getAutoResumeTime()
- Specified by:
getAutoResumeTime
in interfaceDownloadManager
-
setAutoResumeTime
public void setAutoResumeTime(long time)
- Specified by:
setAutoResumeTime
in interfaceDownloadManager
-
stopPausedDownload
public boolean stopPausedDownload()
- Specified by:
stopPausedDownload
in interfaceDownloadManager
-
isPaused
public boolean isPaused()
- Specified by:
isPaused
in interfaceDownloadManager
-
resume
public void resume()
- Specified by:
resume
in interfaceDownloadManager
-
getAssumedComplete
public boolean getAssumedComplete()
Description copied from interface:DownloadManager
Retrieve whether this download is assumed complete.Assumed complete status is kept while the torrent is in a non-running state, even if it has no data.
When the torrent starts up, the real complete level will be checked, and if the torrent actually does have missing data, the download will be thrown into error state.
Only a forced-recheck should clear this flag.
- Specified by:
getAssumedComplete
in interfaceDownloadManager
-
requestAssumedCompleteMode
public boolean requestAssumedCompleteMode()
Description copied from interface:DownloadManager
Will set this download to be "assumed complete" for if the download is already complete (excluding DND)- Specified by:
requestAssumedCompleteMode
in interfaceDownloadManager
- Returns:
- true- success; false- failure, download not complete
-
requestAssumedCompleteMode
protected boolean requestAssumedCompleteMode(boolean filePriorityChanged)
-
setAssumedComplete
protected void setAssumedComplete(boolean _assumedComplete)
-
setAssumedComplete
protected void setAssumedComplete(boolean _assumedComplete, boolean filePriorityChanged)
-
getNbSeeds
public int getNbSeeds()
- Specified by:
getNbSeeds
in interfaceDownloadManager
-
getNbPeers
public int getNbPeers()
- Specified by:
getNbPeers
in interfaceDownloadManager
-
getTrackerStatus
public java.lang.String getTrackerStatus()
- Specified by:
getTrackerStatus
in interfaceDownloadManager
-
getTrackerClient
public TRTrackerAnnouncer getTrackerClient()
- Specified by:
getTrackerClient
in interfaceDownloadManager
-
setAnnounceResult
public void setAnnounceResult(DownloadAnnounceResult result)
- Specified by:
setAnnounceResult
in interfaceDownloadManager
-
setScrapeResult
public void setScrapeResult(DownloadScrapeResult result)
- Specified by:
setScrapeResult
in interfaceDownloadManager
-
getNbPieces
public int getNbPieces()
- Specified by:
getNbPieces
in interfaceDownloadManager
-
getTrackerTime
public int getTrackerTime()
Description copied from interface:DownloadManager
When the next call to the tracker will occur (in seconds)- Specified by:
getTrackerTime
in interfaceDownloadManager
-
getTorrent
public TOTorrent getTorrent()
- Specified by:
getTorrent
in interfaceDownloadManager
-
getSaveLocation
public java.io.File getSaveLocation()
- Specified by:
getSaveLocation
in interfaceDownloadManager
-
getAbsoluteSaveLocation
public java.io.File getAbsoluteSaveLocation()
Description copied from interface:DownloadManager
Returns the file location where we save the torrent, this includes the parent directory and the actual file name.- Specified by:
getAbsoluteSaveLocation
in interfaceDownloadManager
-
setTorrentSaveDir
public void setTorrentSaveDir(java.io.File _new_location, boolean locationIncludesName)
Description copied from interface:DownloadManager
changes the save directory. Only call this if you know what you are doing!!!! When locationIncludesName, torrent name will also change (Data files will be stored under new_location)
When !locationIncludesName, only save dire is changed, name remains (Data files will be stored under new_location + / + old_location.getName())- Specified by:
setTorrentSaveDir
in interfaceDownloadManager
-
getPieceLength
public java.lang.String getPieceLength()
- Specified by:
getPieceLength
in interfaceDownloadManager
-
getTorrentFileName
public java.lang.String getTorrentFileName()
Description copied from interface:DownloadManager
This includes the full path to the torrent file.- Specified by:
getTorrentFileName
in interfaceDownloadManager
- Returns:
-
setTorrentFileName
public void setTorrentFileName(java.lang.String string)
- Specified by:
setTorrentFileName
in interfaceDownloadManager
-
setTrackerScrapeResponse
public void setTrackerScrapeResponse(TRTrackerScraperResponse response)
- Specified by:
setTrackerScrapeResponse
in interfaceDownloadManager
-
getTrackerScrapeResponse
public TRTrackerScraperResponse getTrackerScrapeResponse()
- Specified by:
getTrackerScrapeResponse
in interfaceDownloadManager
-
getActiveScrapeResponse
protected java.lang.Object[] getActiveScrapeResponse()
Returns the "first" online scrape response found, and its active URL, otherwise one of the failing scrapes- Returns:
-
getGoodTrackerScrapeResponses
public java.util.List<TRTrackerScraperResponse> getGoodTrackerScrapeResponses()
- Specified by:
getGoodTrackerScrapeResponses
in interfaceDownloadManager
-
requestTrackerAnnounce
public void requestTrackerAnnounce(boolean force)
- Specified by:
requestTrackerAnnounce
in interfaceDownloadManager
-
requestTrackerScrape
public void requestTrackerScrape(boolean force)
- Specified by:
requestTrackerScrape
in interfaceDownloadManager
-
setTrackerRefreshDelayOverrides
protected void setTrackerRefreshDelayOverrides(int percent)
-
activateRequest
protected boolean activateRequest(int count)
-
getActivationCount
public int getActivationCount()
- Specified by:
getActivationCount
in interfaceDownloadManager
-
getTorrentComment
public java.lang.String getTorrentComment()
- Specified by:
getTorrentComment
in interfaceDownloadManager
-
getTorrentCreatedBy
public java.lang.String getTorrentCreatedBy()
- Specified by:
getTorrentCreatedBy
in interfaceDownloadManager
-
getTorrentCreationDate
public long getTorrentCreationDate()
- Specified by:
getTorrentCreationDate
in interfaceDownloadManager
-
getGlobalManager
public GlobalManager getGlobalManager()
- Specified by:
getGlobalManager
in interfaceDownloadManager
-
getDiskManager
public DiskManager getDiskManager()
- Specified by:
getDiskManager
in interfaceDownloadManager
-
getDiskManagerPiecesSnapshot
public DiskManagerPiece[] getDiskManagerPiecesSnapshot()
- Specified by:
getDiskManagerPiecesSnapshot
in interfaceDownloadManager
-
getDiskManagerFileInfoSet
public DiskManagerFileInfoSet getDiskManagerFileInfoSet()
- Specified by:
getDiskManagerFileInfoSet
in interfaceDownloadManager
-
getDiskManagerFileInfo
public DiskManagerFileInfo[] getDiskManagerFileInfo()
Deprecated.use getDiskManagerFileInfoSet() instead- Specified by:
getDiskManagerFileInfo
in interfaceDownloadManager
-
getNumFileInfos
public int getNumFileInfos()
- Specified by:
getNumFileInfos
in interfaceDownloadManager
-
getPeerManager
public PEPeerManager getPeerManager()
- Specified by:
getPeerManager
in interfaceDownloadManager
-
isDownloadComplete
public boolean isDownloadComplete(boolean bIncludeDND)
Description copied from interface:DownloadManager
Retrieves whether the download is complete- Specified by:
isDownloadComplete
in interfaceDownloadManager
- Parameters:
bIncludeDND
- true- include files marked as Do Not Download.
false- don't include files marked DND.If there are DND files and you choose to include DND in the calculation, false will always be returned.
- Returns:
- whether download is complete
-
addListener
public void addListener(DownloadManagerListener listener)
- Specified by:
addListener
in interfaceDownloadManager
-
addListener
public void addListener(DownloadManagerListener listener, boolean triggerStateChange)
- Specified by:
addListener
in interfaceDownloadManager
-
removeListener
public void removeListener(DownloadManagerListener listener)
- Specified by:
removeListener
in interfaceDownloadManager
-
informStateChanged
protected void informStateChanged()
Doesn't not inform if state didn't change from last inform call
-
informDownloadEnded
protected void informDownloadEnded()
-
informPrioritiesChange
protected void informPrioritiesChange(java.util.List files)
-
informLocationChange
protected void informLocationChange(int file_index)
-
informLocationChange
protected void informLocationChange(DiskManagerFileInfo file)
-
informPriorityChange
protected void informPriorityChange(DiskManagerFileInfo file)
-
informPositionChanged
protected void informPositionChanged(int new_position)
-
addPeerListener
public void addPeerListener(DownloadManagerPeerListener listener)
- Specified by:
addPeerListener
in interfaceDownloadManager
-
addPeerListener
public void addPeerListener(DownloadManagerPeerListener listener, boolean bDispatchForExisting)
- Specified by:
addPeerListener
in interfaceDownloadManager
-
removePeerListener
public void removePeerListener(DownloadManagerPeerListener listener)
- Specified by:
removePeerListener
in interfaceDownloadManager
-
addPieceListener
public void addPieceListener(DownloadManagerPieceListener listener)
- Specified by:
addPieceListener
in interfaceDownloadManager
-
addPieceListener
public void addPieceListener(DownloadManagerPieceListener listener, boolean bDispatchForExisting)
- Specified by:
addPieceListener
in interfaceDownloadManager
-
removePieceListener
public void removePieceListener(DownloadManagerPieceListener listener)
- Specified by:
removePieceListener
in interfaceDownloadManager
-
addPeer
public void addPeer(PEPeer peer)
-
removePeer
public void removePeer(PEPeer peer)
-
getCurrentPeers
public PEPeer[] getCurrentPeers()
- Specified by:
getCurrentPeers
in interfaceDownloadManager
-
addPiece
public void addPiece(PEPiece piece)
-
removePiece
public void removePiece(PEPiece piece)
-
getCurrentPieces
public PEPiece[] getCurrentPieces()
- Specified by:
getCurrentPieces
in interfaceDownloadManager
-
informWillBeStarted
protected void informWillBeStarted(PEPeerManager pm)
-
informStarted
protected void informStarted(PEPeerManager pm)
-
informStopped
protected void informStopped(PEPeerManager pm, boolean for_queue)
-
getStats
public DownloadManagerStats getStats()
- Specified by:
getStats
in interfaceDownloadManager
-
isForceStart
public boolean isForceStart()
- Specified by:
isForceStart
in interfaceDownloadManager
-
setForceStart
public void setForceStart(boolean forceStart)
- Specified by:
setForceStart
in interfaceDownloadManager
-
downloadEnded
protected void downloadEnded(boolean never_downloaded)
Is called when a download is finished. Activates alerts for the user.- Parameters:
never_downloaded
- true indicates that we never actually downloaded anything in this session, but we determined that the download is complete (usually via startDownload())
-
addDiskListener
public void addDiskListener(DownloadManagerDiskListener listener)
- Specified by:
addDiskListener
in interfaceDownloadManager
-
removeDiskListener
public void removeDiskListener(DownloadManagerDiskListener listener)
- Specified by:
removeDiskListener
in interfaceDownloadManager
-
addActivationListener
public void addActivationListener(DownloadManagerActivationListener listener)
- Specified by:
addActivationListener
in interfaceDownloadManager
-
removeActivationListener
public void removeActivationListener(DownloadManagerActivationListener listener)
- Specified by:
removeActivationListener
in interfaceDownloadManager
-
getHealthStatus
public int getHealthStatus()
- Specified by:
getHealthStatus
in interfaceDownloadManager
- Returns:
- the wealthy status of this download
-
getNATStatus
public java.lang.Object[] getNATStatus()
Description copied from interface:DownloadManager
See plugin ConnectionManager.NAT_ constants for return values- Specified by:
getNATStatus
in interfaceDownloadManager
- Returns:
-
getPosition
public int getPosition()
- Specified by:
getPosition
in interfaceDownloadManager
-
setPosition
public void setPosition(int new_position)
- Specified by:
setPosition
in interfaceDownloadManager
-
addTrackerListener
public void addTrackerListener(DownloadManagerTrackerListener listener)
- Specified by:
addTrackerListener
in interfaceDownloadManager
-
removeTrackerListener
public void removeTrackerListener(DownloadManagerTrackerListener listener)
- Specified by:
removeTrackerListener
in interfaceDownloadManager
-
deleteDataFiles
protected void deleteDataFiles()
-
deletePartialDataFiles
protected void deletePartialDataFiles()
-
deleteTorrentFile
protected void deleteTorrentFile()
-
getDownloadState
public DownloadManagerState getDownloadState()
- Specified by:
getDownloadState
in interfaceDownloadManager
-
getUserData
public java.lang.Object getUserData(java.lang.Object key)
To retreive arbitrary objects against a download.- Specified by:
getUserData
in interfaceDownloadManager
-
setUserData
public void setUserData(java.lang.Object key, java.lang.Object value)
To store arbitrary objects against a download.- Specified by:
setUserData
in interfaceDownloadManager
-
getTaggableTransientProperty
public java.lang.Object getTaggableTransientProperty(java.lang.String key)
- Specified by:
getTaggableTransientProperty
in interfaceTaggable
-
setTaggableTransientProperty
public void setTaggableTransientProperty(java.lang.String key, java.lang.Object value)
- Specified by:
setTaggableTransientProperty
in interfaceTaggable
-
isDataAlreadyAllocated
public boolean isDataAlreadyAllocated()
Description copied from interface:DownloadManager
Determine whether disk allocation has already been done. Used for checking if data is missing on a previously-loaded torrent.- Specified by:
isDataAlreadyAllocated
in interfaceDownloadManager
- Returns:
- true if data files have already been allocated
-
setDataAlreadyAllocated
public void setDataAlreadyAllocated(boolean already_allocated)
Description copied from interface:DownloadManager
Set whether data allocation has already been done, so we know when to allocate and when to throw a missing-data error message.- Specified by:
setDataAlreadyAllocated
in interfaceDownloadManager
-
setSeedingRank
public void setSeedingRank(Download.SeedingRank rank)
- Specified by:
setSeedingRank
in interfaceDownloadManager
-
getSeedingRank
public Download.SeedingRank getSeedingRank()
- Specified by:
getSeedingRank
in interfaceDownloadManager
-
getCreationTime
public long getCreationTime()
Description copied from interface:DownloadManager
gives the time this download was created (not the torrent but the download itself)- Specified by:
getCreationTime
in interfaceDownloadManager
- Returns:
-
setCreationTime
public void setCreationTime(long t)
- Specified by:
setCreationTime
in interfaceDownloadManager
-
isSwarmMerging
public boolean isSwarmMerging()
- Specified by:
isSwarmMerging
in interfaceDownloadManager
-
getSwarmMergingInfo
public java.lang.String getSwarmMergingInfo()
- Specified by:
getSwarmMergingInfo
in interfaceDownloadManager
-
getExtendedMessagingMode
public int getExtendedMessagingMode()
- Specified by:
getExtendedMessagingMode
in interfaceDownloadManager
- Returns:
- messaging mode = az, lt or bt
-
setCryptoLevel
public void setCryptoLevel(int level)
- Specified by:
setCryptoLevel
in interfaceDownloadManager
-
getCryptoLevel
public int getCryptoLevel()
- Specified by:
getCryptoLevel
in interfaceDownloadManager
-
getMoveProgress
public long[] getMoveProgress()
Description copied from interface:DownloadManager
Progress of a move operation- Specified by:
getMoveProgress
in interfaceDiskManagerUtil.MoveTaskAapter
- Specified by:
getMoveProgress
in interfaceDownloadManager
- Returns:
- null: not moving otherwise [ 0->1000, size ]
-
getMoveSubTask
public java.lang.String getMoveSubTask()
- Specified by:
getMoveSubTask
in interfaceDiskManagerUtil.MoveTaskAapter
-
setMoveState
public void setMoveState(int state)
- Specified by:
setMoveState
in interfaceDiskManagerUtil.MoveTaskAapter
-
moveDataFiles
public void moveDataFiles(java.io.File new_parent_dir) throws DownloadManagerException
Description copied from interface:DownloadManager
Move data files to new location. Torrent must be in stopped/error state- Specified by:
moveDataFiles
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
moveDataFilesLive
public void moveDataFilesLive(java.io.File new_parent_dir) throws DownloadManagerException
Description copied from interface:DownloadManager
At some point someone made the file-move operations stop+restart the download when it was designed to work without doing this (see move-on-complete for example). As I don't know the reason for this change I've (parg) added a new method to do this in the hope that we might in time migrate back to the 'proper' behaviour. grrr- Specified by:
moveDataFilesLive
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
renameDownload
public void renameDownload(java.lang.String new_name) throws DownloadManagerException
Description copied from interface:DownloadManager
Rename the download - this means the name of the file being downloaded (for single file torrents), or the name of the directory holding the files (in a multi-file torrent). This does not alter the displayed name of the download.- Specified by:
renameDownload
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
moveDataFiles
public void moveDataFiles(java.io.File destination, java.lang.String new_name) throws DownloadManagerException
Description copied from interface:DownloadManager
Move the files and rename a download in one go. For convenience - either argument can be null, but not both.- Specified by:
moveDataFiles
in interfaceDownloadManager
- Parameters:
destination
- new location to move torrent data files to. If null, and simple torrent, torrent data file will be renamed new_name. If null, and not simple torrent, torrent end path will be changed to new_name.new_name
- For simple torrent, changes the filename of the downloaded file. For non-simple torrent, changes the end path for the downloaded files. If null, torrent data files will be moved to new_parent_dir, with a subfolder of the existing name.- Throws:
DownloadManagerException
- See Also:
DownloadManager.moveDataFiles(File)
,DownloadManager.renameDownload(String)
-
moveDataFiles
public void moveDataFiles(java.io.File destination, java.lang.String new_name, boolean live) throws DownloadManagerException
- Throws:
DownloadManagerException
-
moveDataFilesSupport
void moveDataFilesSupport(java.io.File new_parent_dir, java.lang.String new_filename) throws DownloadManagerException
- Throws:
DownloadManagerException
-
moveDataFilesSupport0
void moveDataFilesSupport0(java.io.File new_parent_dir, java.lang.String new_filename) throws DownloadManagerException
- Throws:
DownloadManagerException
-
copyDataFiles
public void copyDataFiles(java.io.File dest_parent_dir) throws DownloadManagerException
- Specified by:
copyDataFiles
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
copyTorrentFile
private void copyTorrentFile(java.io.File parent_dir) throws DownloadManagerException
- Throws:
DownloadManagerException
-
canExportDownload
public boolean canExportDownload()
- Specified by:
canExportDownload
in interfaceDownloadManager
-
exportDownload
public void exportDownload(java.io.File parent_dir) throws DownloadManagerException
- Specified by:
exportDownload
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
moveTorrentFile
public void moveTorrentFile(java.io.File new_parent_dir) throws DownloadManagerException
Description copied from interface:DownloadManager
Move torrent file to new location. Download must be stopped/error- Specified by:
moveTorrentFile
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
moveTorrentFile
public void moveTorrentFile(java.io.File new_parent_dir, java.lang.String new_name) throws DownloadManagerException
- Specified by:
moveTorrentFile
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
moveTorrentFile0
private void moveTorrentFile0(java.io.File new_parent_dir, java.lang.String new_name) throws DownloadManagerException
- Throws:
DownloadManagerException
-
setTorrentFile
public void setTorrentFile(java.io.File new_parent_dir, java.lang.String new_name) throws DownloadManagerException
Description copied from interface:DownloadManager
Sets the torrent file name (will perform a move of the torrent file) - this shouldn't be used unless you know what you are doing (it requires the download to be stopped!) - it is safer to use moveTorrentFile instead.- Specified by:
setTorrentFile
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
isInDefaultSaveDir
public boolean isInDefaultSaveDir()
Description copied from interface:DownloadManager
Returns true if the download is being saved to one of the default save directories.- Specified by:
isInDefaultSaveDir
in interfaceDownloadManager
-
seedPieceRecheck
public boolean seedPieceRecheck()
Description copied from interface:DownloadManager
Gives the download an opportunity to schedule seeding mode piece rechecks if desired- Specified by:
seedPieceRecheck
in interfaceDownloadManager
- Returns:
- true if a piece has been rechecked
-
addRateLimiter
public void addRateLimiter(LimitedRateGroup group, boolean upload)
- Specified by:
addRateLimiter
in interfaceDownloadManager
-
getRateLimiters
public LimitedRateGroup[] getRateLimiters(boolean upload)
- Specified by:
getRateLimiters
in interfaceDownloadManager
-
removeRateLimiter
public void removeRateLimiter(LimitedRateGroup group, boolean upload)
- Specified by:
removeRateLimiter
in interfaceDownloadManager
-
isTrackerError
public boolean isTrackerError()
- Specified by:
isTrackerError
in interfaceDownloadManager
-
isUnauthorisedOnTracker
public boolean isUnauthorisedOnTracker()
- Specified by:
isUnauthorisedOnTracker
in interfaceDownloadManager
-
getTrackerPeerSources
public java.util.List<TrackerPeerSource> getTrackerPeerSources()
- Specified by:
getTrackerPeerSources
in interfaceDownloadManager
-
addTPSListener
public void addTPSListener(DownloadManagerTPSListener listener)
- Specified by:
addTPSListener
in interfaceDownloadManager
-
removeTPSListener
public void removeTPSListener(DownloadManagerTPSListener listener)
- Specified by:
removeTPSListener
in interfaceDownloadManager
-
informTPSChanged
public void informTPSChanged()
- Specified by:
informTPSChanged
in interfaceDownloadManager
-
getIdentity
private byte[] getIdentity()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getRelationText
public java.lang.String getRelationText()
Description copied from class:LogRelation
A short description of what your class holds that can be printed by the logger- Overrides:
getRelationText
in classLogRelation
- Returns:
-
getQueryableInterfaces
public java.lang.Object[] getQueryableInterfaces()
Description copied from class:LogRelation
Query this class for a reference to another class that it may hold- Overrides:
getQueryableInterfaces
in classLogRelation
- Returns:
- If found, the class desired. Otherwise, null.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
generateEvidence
public void generateEvidence(IndentWriter writer)
- Specified by:
generateEvidence
in interfaceDownloadManager
-
destroy
public void destroy(boolean is_duplicate)
Description copied from interface:DownloadManager
Indicates that the download manager is no longer needed- Specified by:
destroy
in interfaceDownloadManager
- Parameters:
is_duplicate
- indicates whether this dm is being destroyed because it is a duplicate
-
isDestroyed
public boolean isDestroyed()
- Specified by:
isDestroyed
in interfaceDownloadManager
-
getStorageType
public int[] getStorageType(DiskManagerFileInfo[] info)
- Specified by:
getStorageType
in interfaceDownloadManager
-
canMoveDataFiles
public boolean canMoveDataFiles()
- Specified by:
canMoveDataFiles
in interfaceDownloadManager
-
rename
public void rename(java.lang.String name) throws DownloadManagerException
Description copied from interface:DownloadManager
Renames the save file, torrent file and the displayed name.- Specified by:
rename
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
renameTorrent
public void renameTorrent(java.lang.String name) throws DownloadManagerException
- Specified by:
renameTorrent
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
renameTorrentSafe
public void renameTorrentSafe(java.lang.String name) throws DownloadManagerException
Description copied from interface:DownloadManager
Same as renameTorrent, but appends numbers if torrent already exists- Specified by:
renameTorrentSafe
in interfaceDownloadManager
- Throws:
DownloadManagerException
-
requestAttention
public void requestAttention()
- Specified by:
requestAttention
in interfaceDownloadManager
-
fireGlobalManagerEvent
public void fireGlobalManagerEvent(int eventType)
- Specified by:
fireGlobalManagerEvent
in interfaceDownloadManager
-
setFilePriorities
public void setFilePriorities(DiskManagerFileInfo[] fileInfos, int priority)
Description copied from interface:DownloadManager
Sets the priority for an array for files- Specified by:
setFilePriorities
in interfaceDownloadManager
-
-