2020from fs .iotools import line_iterator
2121from fs .mode import Mode
2222from fs .path import dirname
23- from cachetools import TTLCache
2423
2524
2625log = logging .getLogger (__name__ )
@@ -157,8 +156,7 @@ class WebDAVFS(FS):
157156 'virtual' : False ,
158157 }
159158
160- def __init__ (self , url , login = None , password = None , root = None ,
161- cache_maxsize = 10000 , cache_ttl = 60 ):
159+ def __init__ (self , url , login = None , password = None , root = None ):
162160 self .url = url
163161 self .root = root
164162 super (WebDAVFS , self ).__init__ ()
@@ -169,8 +167,6 @@ def __init__(self, url, login=None, password=None, root=None,
169167 'webdav_password' : password ,
170168 'root' : self .root
171169 }
172- self .info_cache = TTLCache (maxsize = cache_maxsize ,
173- ttl = cache_ttl )
174170 self .client = wc .Client (options )
175171
176172 def _create_resource (self , path ):
@@ -186,8 +182,7 @@ def _create_info_dict(info):
186182 info_dict = {
187183 'basic' : {"is_dir" : False },
188184 'details' : {'type' : int (ResourceType .file )},
189- 'access' : {},
190- 'other' : {}
185+ 'access' : {}
191186 }
192187
193188 if six .PY2 :
@@ -235,8 +230,9 @@ def exists(self, path):
235230
236231 def getinfo (self , path , namespaces = None ):
237232 _path = self .validatepath (path )
233+ namespaces = namespaces or ()
234+
238235 if _path in '/' :
239- < << << << Updated upstream
240236 info_dict = {
241237 "basic" : {
242238 "name" : "" ,
@@ -261,51 +257,18 @@ def getinfo(self, path, namespaces=None):
261257 raise errors .ResourceNotFound (path , exc = exc )
262258
263259 return Info (info_dict )
264- == == == =
265- self .info_cache .clear ()
266- try :
267- _path = self .validatepath (path )
268- namespaces = namespaces or ()
269- urn = wu .Urn (_path .encode ('utf-8' ))
270- path = self .client .get_full_path (urn );
271- if path in self .info_cache :
272- info = self .info_cache [path ]
273- response = None
274- else :
275- response = self .client .execute_request (action = 'info' ,
276- path = urn .quote ())
277- info = wc .WebDavXmlUtils .parse_info_response (content = response .content , path = path , hostname = self .client .webdav .hostname )
278- if info ['name' ] is None :
279- info ['name' ] = _path .split ("/" )[- 1 ]
280- if wc .WebDavXmlUtils .parse_is_dir_response (content = response .content , path = path , hostname = self .client .webdav .hostname ):
281- info ['isdir' ] = True
282- info ['files' ] = []
283- for i in wc .WebDavXmlUtils .parse_get_list_info_response (response .content ):
284- if i ['path' ].rstrip ('/' ) != path .rstrip ('/' ):
285- self .info_cache [i ['path' ]] = i
286- filename = wu .Urn (i ['path' ], i ['isdir' ]).filename ()
287- if six .PY2 :
288- filename = filename .decode ('utf-8' )
289- filename = filename .rstrip ('/' )
290- info ['files' ].append (filename )
291- self .info_cache [path ] = info
292- info_dict = self ._create_info_dict (info )
293- if info .get ('isdir' , False ):
294- info_dict ['basic' ]['is_dir' ] = True
295- info_dict ['details' ]['type' ] = ResourceType .directory
296- except we .RemoteResourceNotFound as exc :
297- raise errors .ResourceNotFound (path , exc = exc )
298- retval = Info (info_dict )
299- return retval
300- >> >> >> > Stashed changes
301260
302261 def listdir (self , path ):
303- info = self .getinfo (path )
304- if not info .is_dir :
262+ _path = self .validatepath (path )
263+
264+ if not self .getinfo (_path ).is_dir :
305265 raise errors .DirectoryExpected (path )
306- for i in info .raw ['other' ]['files' ]:
307- yield i
308- return
266+
267+ dir_list = self .client .list (_path .encode ('utf-8' ))
268+ if six .PY2 :
269+ dir_list = map (operator .methodcaller ('decode' , 'utf-8' ), dir_list )
270+
271+ return list (map (operator .methodcaller ('rstrip' , '/' ), dir_list ))
309272
310273 def makedir (self , path , permissions = None , recreate = False ):
311274 _path = self .validatepath (path )
0 commit comments