提交 a31cfe4a authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Do not try to put a "delete.me" file in a directory that does not exist.

上级 de47cda1
...@@ -509,6 +509,8 @@ class ModuleCache(object): ...@@ -509,6 +509,8 @@ class ModuleCache(object):
except IOError: except IOError:
has_key = False has_key = False
if not has_key: if not has_key:
#TODO: only if older than 1 week?
# it might still be used by another process
info("clear_unversioned removing cache dir", filename) info("clear_unversioned removing cache dir", filename)
_rmtree(os.path.join(self.dirname, filename)) _rmtree(os.path.join(self.dirname, filename))
...@@ -522,8 +524,10 @@ def _rmtree(parent): ...@@ -522,8 +524,10 @@ def _rmtree(parent):
if not config.nocleanup: if not config.nocleanup:
shutil.rmtree(parent) shutil.rmtree(parent)
except Exception, e: except Exception, e:
# If parent still exists, mark it for deletion by a future refresh()
if os.path.exists(parent):
try: try:
# mark this directory for deletion by a future refresh() info('placing "delete.me" in', parent)
open(os.path.join(parent,'delete.me'), 'w').close() open(os.path.join(parent,'delete.me'), 'w').close()
except Exception, ee: except Exception, ee:
warning('Failed to remove or mark cache directory %s for removal' % parent, ee) warning('Failed to remove or mark cache directory %s for removal' % parent, ee)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论