Module: deluge
Branch: multiuser-oldprefs
Commit: 78e966946feb49c70ff635508aa33602a1526ef1

Author: Pedro Algarvio <[email protected]>
Date:   Mon Apr 25 09:13:45 2011 +0100

Allow setting torrent ownership when adding new torrents.

---

 deluge/core/torrentmanager.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index aeb5068..ad20335 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -329,7 +329,8 @@ class TorrentManager(component.Component):
             log.warning("Unable to delete the fastresume file: %s", e)
 
     def add(self, torrent_info=None, state=None, options=None, save_state=True,
-            filedump=None, filename=None, magnet=None, resume_data=None):
+            filedump=None, filename=None, magnet=None, resume_data=None,
+            owner='localclient'):
         """Add a torrent to the manager and returns it's torrent_id"""
 
         if torrent_info is None and state is None and filedump is None and 
magnet is None:
@@ -447,7 +448,10 @@ class TorrentManager(component.Component):
         # Set auto_managed to False because the torrent is paused
         handle.auto_managed(False)
         # Create a Torrent object
-        owner = state.owner if state else 
component.get("RPCServer").get_session_user()
+        owner = state.owner if state else (owner if owner else 
component.get("RPCServer").get_session_user())
+        account_exists = component.get("AuthManager").has_account(owner)
+        if not account_exists:
+            owner = 'localclient'
         torrent = Torrent(handle, options, state, filename, magnet, owner)
         # Add the torrent object to the dictionary
         self.torrents[torrent.torrent_id] = torrent

-- 
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