Module: deluge
Branch: master
Commit: 65c9dc5fa84e793b64e45ca263eec19896f3ab14

Author: Andrew Resch <[email protected]>
Date:   Sat Aug 21 12:15:41 2010 -0700

Add new torrent status key 'owner' for keeping track of who added the torrent 
to the session

---

 deluge/core/torrent.py        |    9 ++++++++-
 deluge/core/torrentmanager.py |    7 +++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
index d19cbb4..ca2183d 100644
--- a/deluge/core/torrent.py
+++ b/deluge/core/torrent.py
@@ -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,
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index d76d798..f6edc2a 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -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"]:

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to