]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
pyutil: fileutil: make temp dir cleanup more robust against failure during initializa...
authorZooko O'Whielacronx <zooko@zooko.com>
Thu, 26 Apr 2007 22:58:03 +0000 (15:58 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Thu, 26 Apr 2007 22:58:03 +0000 (15:58 -0700)
src/zfec/zfec/util/fileutil.py

index 98c5d9140266fda286b50ffe6b456f20a5724a84..2821c973f083fd5d486572b45f3af4222495296b 100644 (file)
@@ -117,12 +117,13 @@ class _Dir(object):
         self.subdirs.add(dirobj)
        
     def shutdown(self):
-        if self.cleanup and hasattr(self, 'name'):
-            for subdir in self.subdirs:
+        if self.cleanup:
+            for subdir in hasattr(self, 'subdirs') and self.subdirs or []:
                 subdir.shutdown()
-            for fileobj in self.files:
+            for fileobj in hasattr(self, 'files') and self.files or []:
                 fileobj.close() # "close()" is idempotent so we don't need to catch exceptions here
-            rm_dir(self.name)
+            if hasattr(self, 'name'):
+                rm_dir(self.name)
 
     def __repr__(self):
         return "<%s instance at %x %s>" % (self.__class__.__name__, id(self), self.name)