kuuko pushed a commit to branch master.

http://git.enlightenment.org/apps/epour.git/commit/?id=2da968719d83bb41f3c9c2c5affa9c7f09dd3b4b

commit 2da968719d83bb41f3c9c2c5affa9c7f09dd3b4b
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Thu Jul 3 19:38:55 2014 +0300

    Fix file activation to work again
---
 epour/gui/TorrentProps.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/epour/gui/TorrentProps.py b/epour/gui/TorrentProps.py
index bec4a5d..22aa8ba 100644
--- a/epour/gui/TorrentProps.py
+++ b/epour/gui/TorrentProps.py
@@ -22,6 +22,7 @@
 import cgi
 import sys
 import os
+import pipes
 import logging
 log = logging.getLogger("epour")
 
@@ -230,7 +231,6 @@ class TorrentFiles(StandardWindow):
                     construct(value, parent=it)
 
         construct(file_dict)
-        return
 
     def expand_request_cb(self, gl, item):
         item.expanded = True
@@ -279,14 +279,21 @@ class TorrentFiles(StandardWindow):
     def item_activated_cb(self, gl, item):
         if item.type != ELM_GENLIST_ITEM_NONE:
             return
-        file_entry, progress, n, h = item.data
-        if progress != file_entry.size:
+        fn, fe, n = item.data
+        h = gl.data["handle"]
+        progress = h.file_progress()[n]
+
+        if progress == 0:
+            log.error("Tried to open a file with size 0")
             return
 
-        path = os.path.join(h.save_path(), file_entry.path)
+        if progress < fe.size:
+            log.warn("Opening an incomplete file")
+
+        path = os.path.join(h.save_path().rstrip("\0"), fe.path)
 
         if sys.platform == 'linux2':
-            ecore.Exe("xdg-open '{0}'".format(path))
+            ecore.Exe('xdg-open %s' % pipes.quote(path))
         else:
             os.startfile(path)
 

-- 


Reply via email to