Add new torrent status key 'owner' for keeping track of who added the torrent to the session
This commit is contained in:
parent
7e2eea46d3
commit
65c9dc5fa8
|
@ -76,7 +76,7 @@ class TorrentOptions(dict):
|
|||
class Torrent(object):
|
||||
"""Torrent holds information about torrents added to the libtorrent session.
|
||||
"""
|
||||
def __init__(self, handle, options, state=None, filename=None, magnet=None):
|
||||
def __init__(self, handle, options, state=None, filename=None, magnet=None, owner=None):
|
||||
log.debug("Creating torrent object %s", str(handle.info_hash()))
|
||||
# Get the core config
|
||||
self.config = ConfigManager("core.conf")
|
||||
|
@ -179,6 +179,12 @@ class Torrent(object):
|
|||
else:
|
||||
self.time_added = time.time()
|
||||
|
||||
# Keep track of the owner
|
||||
if state:
|
||||
self.owner = state.owner
|
||||
else:
|
||||
self.owner = owner
|
||||
|
||||
log.debug("Torrent object created.")
|
||||
|
||||
## Options methods ##
|
||||
|
@ -592,6 +598,7 @@ class Torrent(object):
|
|||
"next_announce": self.status.next_announce.seconds,
|
||||
"num_peers": self.status.num_peers - self.status.num_seeds,
|
||||
"num_seeds": self.status.num_seeds,
|
||||
"owner": self.owner,
|
||||
"paused": self.status.paused,
|
||||
"prioritize_first_last": self.options["prioritize_first_last_pieces"],
|
||||
"progress": progress,
|
||||
|
|
|
@ -84,7 +84,8 @@ class TorrentState:
|
|||
move_completed=False,
|
||||
move_completed_path=None,
|
||||
magnet=None,
|
||||
time_added=-1
|
||||
time_added=-1,
|
||||
owner=None
|
||||
):
|
||||
self.torrent_id = torrent_id
|
||||
self.filename = filename
|
||||
|
@ -94,6 +95,7 @@ class TorrentState:
|
|||
self.is_finished = is_finished
|
||||
self.magnet = magnet
|
||||
self.time_added = time_added
|
||||
self.owner = owner
|
||||
|
||||
# Options
|
||||
self.compact = compact
|
||||
|
@ -434,7 +436,8 @@ class TorrentManager(component.Component):
|
|||
# Set auto_managed to False because the torrent is paused
|
||||
handle.auto_managed(False)
|
||||
# Create a Torrent object
|
||||
torrent = Torrent(handle, options, state, filename, magnet)
|
||||
owner = state.owner if state else component.get("RPCServer").get_session_user()
|
||||
torrent = Torrent(handle, options, state, filename, magnet, owner)
|
||||
# Add the torrent object to the dictionary
|
||||
self.torrents[torrent.torrent_id] = torrent
|
||||
if self.config["queue_new_to_top"]:
|
||||
|
|
Loading…
Reference in New Issue