Commit 764dfb53 authored by Jonathan Maw's avatar Jonathan Maw
Browse files

_stream.py: workspace_close deletes the stored project reference

This is a part of #222
parent 65b8cc97
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import tarfile
from contextlib import contextmanager
from tempfile import TemporaryDirectory

from ._exceptions import StreamError, ImplError, BstError, set_last_task_error
from ._exceptions import StreamError, ImplError, BstError, set_last_task_error, LoadError, LoadErrorReason
from ._message import Message, MessageType
from ._scheduler import Scheduler, SchedStatus, TrackQueue, FetchQueue, BuildQueue, PullQueue, PushQueue
from ._pipeline import Pipeline, PipelineSelection
@@ -607,6 +607,16 @@ class Stream():
                except OSError as e:
                    raise StreamError("Could not remove  '{}': {}"
                                      .format(workspace.get_absolute_path(), e)) from e
        else:
            workspace_project_cache = self._context.get_workspace_project_cache()
            try:
                workspace_project_cache.remove(workspace.get_absolute_path())
            except LoadError as e:
                # We might be closing a workspace with a deleted directory
                if e.reason == LoadErrorReason.MISSING_FILE:
                    pass
                else:
                    raise

        # Delete the workspace and save the configuration
        workspaces.delete_workspace(element_name)