summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-10-02 17:44:22 +0200
committerValentin David <valentin.david@codethink.co.uk>2018-10-04 16:55:13 +0200
commit26d48cc9c3870eb9ca3dd7816d32b8fe0606414e (patch)
tree85004b28e2a775a4775ba1d87ee44abc67a5fb99
parenteb92e8e9f51b46d03455e9c67441d4dfec0a5795 (diff)
downloadbuildstream-valentindavid/rmtree_oserror-1.2.tar.gz
Catch correct exception from shutil.rmtreevalentindavid/rmtree_oserror-1.2
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.
-rw-r--r--buildstream/utils.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py
index 34c0f898b..992218b5e 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -679,7 +679,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))