From c882bf7db62b8e88398de75c35611c7330aaf528 Mon Sep 17 00:00:00 2001 From: "Harry (Open ERP)" Date: Tue, 14 Apr 2009 13:50:15 +0530 Subject: [PATCH] [DMS]fixing_bug_324823 bzr revid: hmo@tinyerp.com-20090414082015-4bhequho66dy662u --- addons/document/ftpserver/abstracted_fs.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/document/ftpserver/abstracted_fs.py b/addons/document/ftpserver/abstracted_fs.py index 62df4f3b129..3378960024f 100644 --- a/addons/document/ftpserver/abstracted_fs.py +++ b/addons/document/ftpserver/abstracted_fs.py @@ -35,13 +35,13 @@ def _get_month_name(month): def _to_unicode(s): try: - return s.encode('ascii') + return s.decode('utf-8') except UnicodeError: try: - return s.decode('utf-8') + return s.decode('latin') except UnicodeError: try: - return s.decode('latin') + return s.encode('ascii') except UnicodeError: return s @@ -189,17 +189,18 @@ class abstracted_fs: def ftp2fs(self, path_orig, data): path = self.ftpnorm(path_orig) if path and path=='/': - return None - path=_to_unicode(path) + return None path2 = filter(None,path.split('/'))[1:] (cr, uid, pool) = data + if len(path2): + path2[-1]=_to_unicode(path2[-1]) res = pool.get('document.directory').get_object(cr, uid, path2[:]) if not res: raise OSError(2, 'Not such file or directory.') return res # Ok - def fs2ftp(self, node): + def fs2ftp(self, node): res = node and ('/' + node.cr.dbname + '/' + _to_decode(node.path)) or '/' return res @@ -742,8 +743,8 @@ class abstracted_fs: except ValueError: mname=_get_month_name(time.strftime("%m")) mtime = mname+' '+time.strftime("%d %H:%M") - # formatting is matched with proftpd ls output - path=_to_decode(file.path) #file.path.encode('ascii','replace').replace('?','_') + # formatting is matched with proftpd ls output + path=_to_decode(file.path) #file.path.encode('ascii','replace').replace('?','_') yield "%s %3s %-8s %-8s %8s %s %s\r\n" %(perms, nlinks, uname, gname, size, mtime, path.split('/')[-1])