diff options
-rw-r--r-- | buildstream/sandbox/sandbox.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/buildstream/sandbox/sandbox.py b/buildstream/sandbox/sandbox.py index 31d56312d..8cf5fb433 100644 --- a/buildstream/sandbox/sandbox.py +++ b/buildstream/sandbox/sandbox.py @@ -33,6 +33,7 @@ See also: :ref:`sandboxing`. import os from .._exceptions import ImplError, BstError from ..storage._filebaseddirectory import FileBasedDirectory +from ..storage._casbaseddirectory import CasBasedDirectory class SandboxFlags(): @@ -107,6 +108,7 @@ class Sandbox(): self.__scratch = os.path.join(self.__directory, 'scratch') for directory_ in [self._root, self.__scratch]: os.makedirs(directory_, exist_ok=True) + self.__vdir = None def get_directory(self): """Fetches the sandbox root directory @@ -135,8 +137,12 @@ class Sandbox(): (str): The sandbox root directory """ - # For now, just create a new Directory every time we're asked - return FileBasedDirectory(self._root) + if not self.__vdir: + if self.__allow_real_directory: + self.__vdir = FileBasedDirectory(self._root) + else: + self.__vdir = CasBasedDirectory(self.__context, ref=None) + return self.__vdir def get_virtual_toplevel_directory(self): """Fetches the sandbox's toplevel directory |