Commit 15197121 by btimby

Under some conditions, these methods are required. However, there was a bug in

isfile(). It did not properly handle the case of a path within a mountable archive.
parent 9f7b0bcb
......@@ -267,6 +267,28 @@ class ArchiveMountFS(mountfs.MountFS):
return info
return super(ArchiveMountFS, self).getinfo(path)
def isdir(self, path):
"""An isdir() override that allows archives to masquerade as directories. If
the path is not an archive, the call is delegated. In the event that the path
is an archive, that archive is mounted to ensure it can actually be treated
like a directory."""
fs, _mount_path, delegate_path = self._delegate(path)
if isinstance(fs, ArchiveFS) and path == _mount_path:
# If the path is an archive mount point, it is a directory.
return True
return super(ArchiveMountFS, self).isdir(path)
def isfile(self, path):
"""An isfile() override that checks if the given path is a file or not. It is
not fooled by a mounted archive. If the path is not an archive, True is returned.
If the path is not an archive, the call is delegated."""
fs, _mount_path, delegate_path = self._delegate(path)
if isinstance(fs, ArchiveFS) and path == _mount_path:
# If the path is an archive mount point, it is a file.
return True
else:
return fs.isfile(delegate_path)
def getsize(self, path):
"""A getsize() override that returns the size of an archive. It is not fooled by
a mounted archive. If the path is not an archive, the call is delegated."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment