Module: deluge
Branch: 1.3-stable
Commit: 6ad3a770af50e124496502a8d0a0f5669226ea9d

Author: Calum Lind <[email protected]>
Date:   Fri Jun 17 16:14:11 2011 +0100

Add #890: If added torrent already exists, append extra trackers to it

---

 ChangeLog                     |   13 +++++++------
 deluge/core/torrentmanager.py |   27 +++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c06e57b..cd3a2fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,20 +1,21 @@
 === Deluge 1.3.3 (In Development) ===
 ==== Core ====
        * Properly show the 'Checking Resume Data' state instead of just 7
-       * Fix #1788: Added ability to use XDG_DOWNLOAD_DIR as default download 
folder
+       * #1788: Added ability to use XDG_DOWNLOAD_DIR as default download 
folder
        * Fix path error with torrent files prefixed with 'file://' from Firefox
-       * Fix #1869: Set the disk io read/write to bypass OS cache in Windows
-       * Fix #1504: Win32 run deluged as not logged in user via runas or 
service
+       * #1869: Fix setting the disk io read/write to bypass OS cache in 
Windows
+       * #1504: Fix win32 running deluged as not logged in user via runas or 
service
+       * #890: If added torrent already exists, append extra trackers to it
 
 ==== GtkUI ====
        * Show the checking icon for torrents in the 'Checking Resume Data' 
state
        * #1195: Fix right-click selecting issue when switching between folders 
and files
        * Add F2 key shortcut for renaming filenames in the Files Tab
        * Increase max piece size to 16 MiB in create torrent dialog
-       * Fix #1475: Save and restore Preferences dialog size from config
+       * #1475: Fix save and restore Preferences dialog size from config
        * Add search as you type to the torrent view
-       * Fix #1456: No ETA showing with multiple files
-       * Fix #1560: FilesTab Progress value sorting by int instead of float
+       * #1456: Fix no ETA showing with multiple files
+       * #1560: Fix FilesTab Progress value sorting by int instead of float
 
 === AutoAdd ===
        * #1861: Fix AutoAdd Warning (column number is a boolean)
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index bdd0de7..6b6d061 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -409,6 +409,33 @@ class TorrentManager(component.Component):
         add_torrent_params["auto_managed"] = False
         add_torrent_params["duplicate_is_error"] = True
 
+        # If torrent already exists just append any extra trackers.
+        add_torrent_id = str(add_torrent_params["ti"].info_hash())
+        if add_torrent_id in self.get_torrent_list():
+            log.debug("Torrent (%s) exists, checking for trackers to add...", 
add_torrent_id)
+            add_torrent_trackers = []
+            for value in add_torrent_params["ti"].trackers():
+                tracker = {}
+                tracker["url"] = value.url
+                tracker["tier"] = value.tier
+                add_torrent_trackers.append(tracker)
+
+            torrent_trackers = {}
+            tracker_list = []
+            for tracker in  
self[add_torrent_id].get_status(["trackers"])["trackers"]:
+                torrent_trackers[(tracker["url"])] = tracker
+                tracker_list.append(tracker)
+
+            added_tracker = False
+            for tracker in add_torrent_trackers:
+                if tracker['url'] not in torrent_trackers:
+                    tracker_list.append(tracker)
+                    added_tracker = True
+
+            if added_tracker:
+                self[add_torrent_id].set_trackers(tracker_list)
+            return
+
         # We need to pause the AlertManager momentarily to prevent alerts
         # for this torrent being generated before a Torrent object is created.
         component.pause("AlertManager")

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