|
def _find_object_for_path(self, path): |
|
if not self.content_object: |
|
return None |
makes it impossible to create things starting from scratch using SFTPServer(content_object={}) because e.g. mkdir('test') invokes self._get_path_components('test') which returns ('', 'test') and then self._find_object_for_path('') returns None instead of the global storage object.
(the default content_object should be {} and not None too)
Fixed ContentProvider is
class FixedContentProvider(ContentProvider): # fixes default content_object
def __init__(self, content_object=None):
self.content_object = content_object or {}
def is_dir(self, path): # fixes wrong mode attr on binary uploads
return not isinstance(self.get(path), (bytes, str, int))
def _find_object_for_path(self, path): # fixes adding to empty storage
if path == '':
return self.content_object
else:
return super()._find_object_for_path(path)
pytest-sftpserver/pytest_sftpserver/sftp/content_provider.py
Lines 75 to 77 in 8f90e80
makes it impossible to create things starting from scratch using
SFTPServer(content_object={})because e.g.mkdir('test')invokesself._get_path_components('test')which returns('', 'test')and thenself._find_object_for_path('')returnsNoneinstead of the global storage object.(the default content_object should be
{}and notNonetoo)Fixed ContentProvider is