Author: andar
Revision: 5322
Log:
Optimize get_tracker_host by storing the tracker_host value
Diff:
Modified: trunk/deluge/core/torrent.py
===================================================================
--- trunk/deluge/core/torrent.py 2009-05-28 19:16:28 UTC (rev 5321)
+++ trunk/deluge/core/torrent.py 2009-05-28 19:16:58 UTC (rev 5322)
@@ -1,7 +1,7 @@
#
# torrent.py
#
-# Copyright (C) 2007, 2008 Andrew Resch <[email protected]>
+# Copyright (C) 2007-2009 Andrew Resch <[email protected]>
#
# Deluge is free software.
#
@@ -31,9 +31,7 @@
# this exception statement from your version. If you delete this exception
# statement from all source files in the program, then also delete it here.
#
-#
-
"""Internal Torrent class"""
import os
@@ -64,15 +62,15 @@
"max_upload_speed": "max_upload_speed_per_torrent",
"max_download_speed":
"max_download_speed_per_torrent",
"prioritize_first_last_pieces":
"prioritize_first_last_pieces",
- "compact_allocation": "compact_allocation",
+ "compact_allocation": "compact_allocation",
"download_location": "download_location",
"auto_managed": "auto_managed",
"stop_at_ratio": "stop_seed_at_ratio",
"stop_ratio": "stop_seed_ratio",
"remove_at_ratio": "remove_seed_at_ratio",
- "move_completed": "move_completed",
+ "move_completed": "move_completed",
"move_completed_path": "move_completed_path",
- "add_paused": "add_paused",
+ "add_paused": "add_paused",
}
for opt_k, conf_k in options_conf_map.iteritems():
self[opt_k] = config[conf_k]
@@ -166,6 +164,9 @@
# The tracker status
self.tracker_status = ""
+ # This gets updated when get_tracker_host is called
+ self.tracker_host = None
+
if state:
self.time_added = state.time_added
else:
@@ -293,6 +294,7 @@
tracker["tier"] = value.tier
trackers.append(tracker)
self.trackers = trackers
+ self.tracker_host = None
return
log.debug("Setting trackers for %s: %s", self.torrent_id, trackers)
@@ -314,6 +316,8 @@
# Force a reannounce if there is at least 1 tracker
self.force_reannounce()
+ self.tracker_host = None
+
### End Options methods ###
def set_save_path(self, save_path):
@@ -494,6 +498,9 @@
def get_tracker_host(self):
"""Returns just the hostname of the currently connected tracker
if no tracker is connected, it uses the 1st tracker."""
+ if self.tracker_host:
+ return self.tracker_host
+
if not self.status:
self.status = self.handle.status()
@@ -521,6 +528,7 @@
host = ".".join(parts[-3:])
else:
host = ".".join(parts[-2:])
+ self.tracker_host = host
return host
return ""
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---