Module: deluge
Branch: master
Commit: b1e0dd66ebf75d58531a74f2346764c32b6ba8d5

Author: Nick Lanham <[email protected]>
Date:   Tue Apr 26 13:53:11 2011 +0200

handle files with [ and ] characters in them

---

 deluge/ui/console/modes/add_util.py |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/deluge/ui/console/modes/add_util.py 
b/deluge/ui/console/modes/add_util.py
index bdd235e..b741a6a 100644
--- a/deluge/ui/console/modes/add_util.py
+++ b/deluge/ui/console/modes/add_util.py
@@ -43,7 +43,23 @@ import deluge.common
 
 import os,base64,glob
 
+import logging
+log = logging.getLogger(__name__)
 
+def __bracket_fixup(path):
+    if (path.find("[") == -1 and
+        path.find("]") == -1):
+        return path
+    sentinal = 256
+    while (path.find(unichr(sentinal)) != -1):
+        sentinal+=1
+        if sentinal > 65535: 
+            log.error("Can't fix brackets in path, path contains all possible 
sentinal characters")
+            return path
+    newpath = path.replace("]",unichr(sentinal))
+    newpath = newpath.replace("[","[[]")
+    newpath = newpath.replace(unichr(sentinal),"[]]")
+    return newpath
 
 def add_torrent(t_file, options, success_cb, fail_cb, ress):
     t_options = {}
@@ -57,7 +73,7 @@ def add_torrent(t_file, options, success_cb, fail_cb, ress):
     if is_url or is_mag:
         files = [t_file]
     else:
-        files = glob.glob(t_file)
+        files = glob.glob(__bracket_fixup(t_file))
     num_files = len(files)
     ress["total"] = num_files
 

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