Skip to content

CachingFileSystem implicitly implies that the file object of the wrapped fs uses the property .cache #209

@ZhengKeli

Description

@ZhengKeli

I found that the current implementation of CachingFileSystem implicitly requires that the file object of wrapped fs uses the property .cache.

https://github.com/fsspec/filesystem_spec/blob/f84b99f0d1f079f990db1a219b74df66ab3e7160/fsspec/implementations/cached.py#L388-L390

However, not all implementation uses the property .cache. I am currently facing an issue that the file object of WebdavFileSystem (from https://github.com/skshetry/webdav4) does overrides method .read() ignoring .cache. Because of that, nothing is cached when I wrap a WebdavFileSystem object with CachingFileSystem.

def read(self, length: int = -1) -> Union[str, bytes, None]:
"""Read chunk of bytes."""
chunk = self.reader.read(length)
if chunk:
self.loc += len(chunk)
return chunk

In my opinion, a wrapper like CachingFileSystem should not imply how the wrapped object works. Perhaps a more general solution should be implemented here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions