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):
|
class Torrent(object):
|
||||||
"""Torrent holds information about torrents added to the libtorrent session.
|
"""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()))
|
log.debug("Creating torrent object %s", str(handle.info_hash()))
|
||||||
# Get the core config
|
# Get the core config
|
||||||
self.config = ConfigManager("core.conf")
|
self.config = ConfigManager("core.conf")
|
||||||
|
@ -179,6 +179,12 @@ class Torrent(object):
|
||||||
else:
|
else:
|
||||||
self.time_added = time.time()
|
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.")
|
log.debug("Torrent object created.")
|
||||||
|
|
||||||
## Options methods ##
|
## Options methods ##
|
||||||
|
@ -592,6 +598,7 @@ class Torrent(object):
|
||||||
"next_announce": self.status.next_announce.seconds,
|
"next_announce": self.status.next_announce.seconds,
|
||||||
"num_peers": self.status.num_peers - self.status.num_seeds,
|
"num_peers": self.status.num_peers - self.status.num_seeds,
|
||||||
"num_seeds": self.status.num_seeds,
|
"num_seeds": self.status.num_seeds,
|
||||||
|
"owner": self.owner,
|
||||||
"paused": self.status.paused,
|
"paused": self.status.paused,
|
||||||
"prioritize_first_last": self.options["prioritize_first_last_pieces"],
|
"prioritize_first_last": self.options["prioritize_first_last_pieces"],
|
||||||
"progress": progress,
|
"progress": progress,
|
||||||
|
|
|
@ -84,7 +84,8 @@ class TorrentState:
|
||||||
move_completed=False,
|
move_completed=False,
|
||||||
move_completed_path=None,
|
move_completed_path=None,
|
||||||
magnet=None,
|
magnet=None,
|
||||||
time_added=-1
|
time_added=-1,
|
||||||
|
owner=None
|
||||||
):
|
):
|
||||||
self.torrent_id = torrent_id
|
self.torrent_id = torrent_id
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
|
@ -94,6 +95,7 @@ class TorrentState:
|
||||||
self.is_finished = is_finished
|
self.is_finished = is_finished
|
||||||
self.magnet = magnet
|
self.magnet = magnet
|
||||||
self.time_added = time_added
|
self.time_added = time_added
|
||||||
|
self.owner = owner
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
self.compact = compact
|
self.compact = compact
|
||||||
|
@ -434,7 +436,8 @@ class TorrentManager(component.Component):
|
||||||
# Set auto_managed to False because the torrent is paused
|
# Set auto_managed to False because the torrent is paused
|
||||||
handle.auto_managed(False)
|
handle.auto_managed(False)
|
||||||
# Create a Torrent object
|
# 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
|
# Add the torrent object to the dictionary
|
||||||
self.torrents[torrent.torrent_id] = torrent
|
self.torrents[torrent.torrent_id] = torrent
|
||||||
if self.config["queue_new_to_top"]:
|
if self.config["queue_new_to_top"]:
|
||||||
|
|
Loading…
Reference in New Issue