From: zooko Date: Thu, 26 Apr 2007 22:58:03 +0000 (+0530) Subject: pyutil: fileutil: make temp dir cleanup more robust against failure during initializa... X-Git-Url: https://git.rkrishnan.org/pf/content/%22file:/frontends/reliability?a=commitdiff_plain;h=af370a14bfd102b4e2a634167b9af1fe7f995dc0;p=tahoe-lafs%2Fzfec.git pyutil: fileutil: make temp dir cleanup more robust against failure during initializationor other internal inconsistency darcs-hash:5b289467c2fddddb2bd35acaadb34fb1c27c685c --- diff --git a/zfec/zfec/util/fileutil.py b/zfec/zfec/util/fileutil.py index 98c5d91..2821c97 100644 --- a/zfec/zfec/util/fileutil.py +++ b/zfec/zfec/util/fileutil.py @@ -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)