From d913814dd969892f2e3025f160fe4e488b3a98b5 Mon Sep 17 00:00:00 2001 From: btimby Date: Thu, 18 Oct 2012 02:35:37 +0000 Subject: __del__() is inherited from FS and redundant. Synchronize the close() methods. Ensure the close() methods close and del referenced file systems. git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@823 67cdc799-7952-0410-af00-57a81ceafa0f --- fs/contrib/archivefs.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/contrib/archivefs.py b/fs/contrib/archivefs.py index d5dd69f..780f1bb 100644 --- a/fs/contrib/archivefs.py +++ b/fs/contrib/archivefs.py @@ -79,9 +79,6 @@ class ArchiveFS(FS): else: self.contents[part] = libarchive.Entry(pathname=part, mode=stat.S_IFDIR, size=0, mtime=item.mtime) - def __del__(self): - self.close() - def __str__(self): return "" % self.root_path @@ -93,6 +90,7 @@ class ArchiveFS(FS): return self.read_only return super(ArchiveFS, self).getmeta(meta_name, default) + @synchronize def close(self): if getattr(self, 'archive', None) is None: return @@ -185,10 +183,12 @@ class ArchiveMountFS(mountfs.MountFS): self.rootfs = rootfs self.mountdir('/', rootfs) - def __del__(self): - # Close (if requested by auto_close, why by default is True) when - # de-referenced. - self.close() + @synchronize + def close(self): + # Close and delete references to any other fs instances. + self.rootfs.close() + del self.rootfs + super(ArchiveMountFS, self).close() def ismount(self, path): "Checks if the given path has a file system mounted on it." -- cgit v1.2.1