summaryrefslogtreecommitdiffstats
path: root/src/py-libs/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/py-libs/util.py')
-rw-r--r--src/py-libs/util.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/py-libs/util.py b/src/py-libs/util.py
index 7f06e27..8cd8b3f 100644
--- a/src/py-libs/util.py
+++ b/src/py-libs/util.py
@@ -55,19 +55,20 @@ def rmtree(path, *args, **kargs):
"""version os shutil.rmtree that ignores no-such-file-or-directory errors,
and tries harder if it finds immutable files"""
tryAgain = 1
- triedTwice = 0
+ failedFilename = None
while tryAgain:
tryAgain = 0
try:
shutil.rmtree(path, *args, **kargs)
except OSError, e:
- if triedTwice: raise
if e.errno == 2: # no such file or directory
pass
- elif e.errno==1:
+ elif e.errno==1 or e.errno==13:
tryAgain = 1
- triedTwice = 1
- os.system("chattr -i -R %s" % path)
+ if failedFilename == e.filename:
+ raise
+ failedFilename = e.filename
+ os.system("chattr -R -i %s" % path)
else:
raise