Module: deluge
Branch: 1.3-stable
Commit: 60f3d32de75f63087cbbad226848a5a2d95a359d

Author: John Garland <[email protected]>
Date:   Sun May  9 16:29:35 2010 +1000

Raise IconsError instead of IndexError (fixes infinite looping)

---

 deluge/ui/tracker_icons.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py
index d4823e5..1fb062e 100644
--- a/deluge/ui/tracker_icons.py
+++ b/deluge/ui/tracker_icons.py
@@ -306,6 +306,8 @@ class TrackerIcons(Component):
         :returns: a Deferred which fires with the downloaded icon's filename
         :rtype: Deferred
         """
+        if len(icons) == 0:
+            raise NoIconsError, "empty icons list"
         (url, mimetype) = icons.pop(0)
         d = download_file(url, os.path.join(self.dir, host_to_icon_name(host, 
mimetype)),
                           force_filename=True)
@@ -354,7 +356,7 @@ class TrackerIcons(Component):
                                callbackArgs=(host,), errbackArgs=(host,))
         elif f.check(error.NoResource, error.ForbiddenResource) and icons:
             d = self.download_icon(icons, host)
-        elif f.check(IndexError, HTMLParseError):
+        elif f.check(NoIconsError, HTMLParseError):
             # No icons, try favicon.ico as an act of desperation
             d = self.download_icon([(urljoin(self.host_to_url(host), 
"favicon.ico"), extension_to_mimetype("ico"))], host)
             d.addCallbacks(self.on_download_icon_complete, 
self.on_download_icon_fail,
@@ -536,3 +538,8 @@ def extension_to_mimetype(extension):
     :raises KeyError: if given an invalid filename extension
     """
     return MIME_MAP[extension.lower()]
+
+################################## EXCEPTIONS #################################
+
+class NoIconsError(Exception):
+    pass

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