diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-01 21:59:01 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-04-01 21:59:01 +0900 |
commit | aa8410d88b78403f37328e4c954a9636a276c564 (patch) | |
tree | 1b1364233406a20d7ad8a879e8a8b03aef65548b | |
parent | 63d9946357d655b0af56202d4fba37ae3f8c5f06 (diff) | |
download | buildstream-aa8410d88b78403f37328e4c954a9636a276c564.tar.gz |
_workspaces.py: Dont unconditionally create workspace local state file at startup.
Fixes issue #257
-rw-r--r-- | buildstream/_workspaces.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/buildstream/_workspaces.py b/buildstream/_workspaces.py index f0118ec36..e221ca7a9 100644 --- a/buildstream/_workspaces.py +++ b/buildstream/_workspaces.py @@ -273,7 +273,7 @@ class Workspaces(): for element, workspace in _yaml.node_items(self._workspaces) } } - + os.makedirs(os.path.join(self._project.directory, ".bst"), exist_ok=True) _yaml.dump(_yaml.node_sanitize(config), os.path.join(self._project.directory, ".bst", "workspaces.yml")) @@ -291,15 +291,17 @@ class Workspaces(): # bravo.bst: /home/me/bravo # def __load_config(self): - os.makedirs(os.path.join(self._project.directory, ".bst"), exist_ok=True) workspace_file = os.path.join(self._project.directory, ".bst", "workspaces.yml") try: - open(workspace_file, "a").close() - except IOError as e: - raise LoadError(LoadErrorReason.MISSING_FILE, - "Could not load workspace config: {}".format(e)) from e + node = _yaml.load(workspace_file) + except LoadError as e: + if e.reason == LoadErrorReason.MISSING_FILE: + # Return an empty dict if there was no workspace file + return {} + + raise - return _yaml.load(workspace_file) + return node # __parse_workspace_config_format() # |