From a79842185f3e762154002c6e928da30d6745568b Mon Sep 17 00:00:00 2001 From: Valentin David Date: Tue, 2 Oct 2018 17:44:22 +0200 Subject: Catch correct exception from shutil.rmtree 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. --- buildstream/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)) -- cgit v1.2.1