Author: andar

Revision: 5941

Log:
        Fix issues adding magnet uris

Diff:
Modified: branches/1.2_RC/deluge/ui/gtkui/addtorrentdialog.py
===================================================================
--- branches/1.2_RC/deluge/ui/gtkui/addtorrentdialog.py 2009-11-19 02:39:07 UTC 
(rev 5940)
+++ branches/1.2_RC/deluge/ui/gtkui/addtorrentdialog.py 2009-11-19 04:51:19 UTC 
(rev 5941)
@@ -226,7 +226,11 @@
         new_row = None
 
         for uri in uris:
-            info_hash = base64.b32decode(uri.split("&")[0][20:]).encode("hex")
+            s = uri.split("&")[0][20:]
+            if len(s) == 32:
+                info_hash = base64.b32decode(s).encode("hex")
+            elif len(s) == 40:
+                info_hash = s
             if info_hash in self.infos:
                 log.debug("Torrent already in list!")
                 continue

Modified: branches/1.2_RC/deluge/ui/gtkui/ipcinterface.py
===================================================================
--- branches/1.2_RC/deluge/ui/gtkui/ipcinterface.py     2009-11-19 02:39:07 UTC 
(rev 5940)
+++ branches/1.2_RC/deluge/ui/gtkui/ipcinterface.py     2009-11-19 04:51:19 UTC 
(rev 5941)
@@ -71,7 +71,9 @@
         _args = []
         for arg in args:
             if arg.strip():
-                _args.append(os.path.abspath(arg))
+                if not deluge.common.is_magnet(arg) and not 
deluge.common.is_url(arg):
+                    arg = os.path.abspath(arg)
+                _args.append(arg)
         args = _args
 
         socket = os.path.join(deluge.configmanager.get_config_dir("ipc"), 
"deluge-gtk")

Modified: trunk/deluge/ui/gtkui/addtorrentdialog.py
===================================================================
--- trunk/deluge/ui/gtkui/addtorrentdialog.py   2009-11-19 02:39:07 UTC (rev 
5940)
+++ trunk/deluge/ui/gtkui/addtorrentdialog.py   2009-11-19 04:51:19 UTC (rev 
5941)
@@ -226,7 +226,11 @@
         new_row = None
 
         for uri in uris:
-            info_hash = base64.b32decode(uri.split("&")[0][20:]).encode("hex")
+            s = uri.split("&")[0][20:]
+            if len(s) == 32:
+                info_hash = base64.b32decode(s).encode("hex")
+            elif len(s) == 40:
+                info_hash = s
             if info_hash in self.infos:
                 log.debug("Torrent already in list!")
                 continue

Modified: trunk/deluge/ui/gtkui/ipcinterface.py
===================================================================
--- trunk/deluge/ui/gtkui/ipcinterface.py       2009-11-19 02:39:07 UTC (rev 
5940)
+++ trunk/deluge/ui/gtkui/ipcinterface.py       2009-11-19 04:51:19 UTC (rev 
5941)
@@ -71,7 +71,9 @@
         _args = []
         for arg in args:
             if arg.strip():
-                _args.append(os.path.abspath(arg))
+                if not deluge.common.is_magnet(arg) and not 
deluge.common.is_url(arg):
+                    arg = os.path.abspath(arg)
+                _args.append(arg)
         args = _args
 
         socket = os.path.join(deluge.configmanager.get_config_dir("ipc"), 
"deluge-gtk")


--

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


Reply via email to