Commit f5fca02f by btimby

Take advantage of MountFS.close(), allow turning auto_mount off.

parent 82cfcf09
......@@ -195,15 +195,15 @@ class ArchiveFS(FS):
class ArchiveMountFS(mountfs.MountFS):
'''A subclass of MountFS that automatically identifies archives. Once identified
archives are mounted in place of the archive file.'''
def __init__(self, rootfs, **kwargs):
super(ArchiveMountFS, self).__init__(**kwargs)
def __init__(self, rootfs, auto_mount=True):
self.auto_mount = auto_mount
super(ArchiveMountFS, self).__init__(auto_close=True)
self.rootfs = rootfs
self.mountdir('/', rootfs)
def __del__(self):
# Umount everything that we mounted.
for mountpoint in self.mount_tree.keys():
self.unmount(mountpoint)
# Close automatically.
self.close()
def ismount(self, path):
try:
......@@ -213,6 +213,7 @@ class ArchiveMountFS(mountfs.MountFS):
return type(object) is mountfs.MountFS.DirMount
def _delegate(self, path):
if self.auto_mount:
for ppath in recursepath(path)[1:]:
# Don't mount again...
if self.ismount(ppath):
......
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