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-06-12 17:38:01 +0100 |
commit | f19a23339688e0cde846112764783f757c524b6a (patch) | |
tree | 87a6f93fd1ee7aaa0514cf38cd5cf0833b51d2e8 | |
parent | acd17d31095e7ef88f142e17e562265effdc9ac1 (diff) | |
download | buildstream-jmac/cas_virtual_directory_2.tar.gz |
sandbox.py: Make get_directory return a CasBasedDirectory.jmac/cas_virtual_directory_2
-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 |