conduit r1755 - in trunk: . conduit



Author: jstowers
Date: Tue Oct  7 22:10:25 2008
New Revision: 1755
URL: http://svn.gnome.org/viewvc/conduit?rev=1755&view=rev

Log:
2008-10-07  John Stowers  <john stowers gmail com>

	* conduit/Vfs.py: This patch fix two possible errors:
	1) sync with directories with a ? fails (sanitize is called with %3F instead of
	? so it doesn't work)
	2) if you sync a directory called ? and replace the ? with a space sync fails
	because you can't create a directory called " " (at least on vfat).
    Fixes #555421 (Luca Ognibene)



Modified:
   trunk/ChangeLog
   trunk/conduit/Vfs.py

Modified: trunk/conduit/Vfs.py
==============================================================================
--- trunk/conduit/Vfs.py	(original)
+++ trunk/conduit/Vfs.py	Tue Oct  7 22:10:25 2008
@@ -4,6 +4,7 @@
 import time
 log = logging.getLogger("Vfs")
 
+import urllib
 import conduit
 import conduit.utils.Singleton as Singleton
 
@@ -140,6 +141,7 @@
     Also see:    
     http://bugzilla.gnome.org/show_bug.cgi?id=309584#c20
     """
+    
     uri = conduit.utils.ensure_string(uri)
     import string
 
@@ -153,6 +155,10 @@
 
     illegal = ILLEGAL_CHARS.get(filesystem,None)
     if illegal:
+        
+        #call urllib.unescape otherwise for example ? is rapresented as %3F
+        uri = urllib.unquote(uri)
+
         #dont escape the scheme part
         idx = uri.rfind("://")
         if idx == -1:
@@ -160,12 +166,14 @@
         else:
             start = idx + 3        
 
-        #replace illegal chars with a space, ignoring the scheme
-        return uri[0:start]+uri[start:].translate(string.maketrans(
-                                                illegal,
-                                                " "*len(illegal)
-                                                )
-                                            )
+        #replace illegal chars with a -, ignoring the scheme (don't use a space because you can't create a directory with just a space)
+        ret = uri[0:start]+uri[start:].translate(string.maketrans(
+                illegal,
+                "_"*len(illegal)
+                )
+                                                 )
+        ret = uri[0:start]+urllib.quote (ret[start:])
+        return ret
     return uri
     
 def uri_is_folder(uri):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]