diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-06-04 10:57:54 +0100 |
---|---|---|
committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-07-24 14:39:03 +0100 |
commit | 1a2b75ab5a8d25843f441c6e486f09cd48c9a79d (patch) | |
tree | 92f2a7c1b0f54092f128ff86141cc7f25d27cbda | |
parent | bd6bbc03132096b72faf87bb3362f63cfdacb13f (diff) | |
download | buildstream-1a2b75ab5a8d25843f441c6e486f09cd48c9a79d.tar.gz |
sandbox.py: Make get_directory return a CasBasedDirectory.
-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 f3cab41ec..bbbe1bc5a 100644 --- a/buildstream/sandbox/sandbox.py +++ b/buildstream/sandbox/sandbox.py @@ -31,6 +31,7 @@ See also: :ref:`sandboxing`. import os from .._exceptions import ImplError, BstError from ..storage._filebaseddirectory import FileBasedDirectory +from ..storage._casbaseddirectory import CasBasedDirectory class SandboxFlags(): @@ -105,6 +106,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 @@ -133,8 +135,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 |