diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-13 16:14:00 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-13 16:14:00 +0900 |
commit | 446875be50996de0c1447af43de75d1f7b037219 (patch) | |
tree | c79d4e1b1e5643df5e647f4e2cb2b13847155763 | |
parent | a968bab76201856a67c876be25745fee912c136b (diff) | |
download | buildstream-446875be50996de0c1447af43de75d1f7b037219.tar.gz |
element.py: Force remove artifact assembly directory on failure to commit
This is there because an ArtifactError on failure to commit indicates
some permissions issue with the directory structure, and it's better
to not leave this dangling behind for users to deal with.
-rw-r--r-- | buildstream/element.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index a956246d9..05c92aa19 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -38,7 +38,7 @@ import shutil from . import _yaml from ._yaml import CompositePolicy from ._variables import Variables -from .exceptions import _BstError +from .exceptions import _BstError, _ArtifactError from . import LoadError, LoadErrorReason, ElementError, ImplError from . import Plugin, Consistency from .project import BST_ARTIFACT_VERSION as BST_CORE_ARTIFACT_VERSION @@ -1113,7 +1113,15 @@ class Element(Plugin): _yaml.dump(_yaml.node_sanitize(meta), os.path.join(metadir, 'artifact.yaml')) with self.timed_activity("Caching Artifact"): - self.__artifacts.commit(self, assembledir) + try: + self.__artifacts.commit(self, assembledir) + except _ArtifactError: + # If we failed to commit, there is a good chance it is because + # of some permission error, we force remove it now because + # it may cause some annoyance to the user who might not be able + # to easily remove the directory without changing permissions. + utils._force_rmtree(assembledir) + raise # Finally cleanup the build dir cleanup_rootdir() |