summaryrefslogtreecommitdiff
path: root/buildstream/utils.py
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-10-02 17:44:22 +0200
committerValentin David <valentin.david@gmail.com>2018-10-04 14:56:09 +0000
commita79842185f3e762154002c6e928da30d6745568b (patch)
treec973c1c583117153c694b2ac26c8922e0ad59afa /buildstream/utils.py
parent8630bac464a9b98654485a2b8699eb38083b0eb5 (diff)
downloadbuildstream-valentindavid/rmtree_oserror.tar.gz
Catch correct exception from shutil.rmtreevalentindavid/rmtree_oserror
Python documentation is not clear on what shutil.rmtree is supposed to raise. However from the source code, it is obvious that OSError are raised, but never shutil.Error. It is not easy to test in normal condition because issues happen usually in combination with a FUSE filesystem, a probably a race condition where `fstatat` returns an error just before the filesystem being unmounted. Fixes #153.
Diffstat (limited to 'buildstream/utils.py')
-rw-r--r--buildstream/utils.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py
index 5c11a363c..3ef1c4356 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -686,7 +686,7 @@ def _force_rmtree(rootpath, **kwargs):
try:
shutil.rmtree(rootpath, **kwargs)
- except shutil.Error as e:
+ except OSError as e:
raise UtilError("Failed to remove cache directory '{}': {}"
.format(rootpath, e))