diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-09-14 13:38:41 +0100 |
---|---|---|
committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-09-19 16:16:28 +0100 |
commit | 6eacca219fe79c0cce97fa0f5c33b942904bc8e6 (patch) | |
tree | 2754f3aa4f06274da2df72f0822e4458ef836b4e | |
parent | c2af0d5108c333cafd877670e86f61c84238c8f9 (diff) | |
download | buildstream-6eacca219fe79c0cce97fa0f5c33b942904bc8e6.tar.gz |
Add some more asserts to check early that we're not doing the wrong thing with CAS
-rw-r--r-- | buildstream/sandbox/_mount.py | 3 | ||||
-rw-r--r-- | buildstream/sandbox/_sandboxbwrap.py | 5 | ||||
-rw-r--r-- | buildstream/sandbox/_sandboxremote.py | 1 |
3 files changed, 7 insertions, 2 deletions
diff --git a/buildstream/sandbox/_mount.py b/buildstream/sandbox/_mount.py index 49068fe92..b516d89cf 100644 --- a/buildstream/sandbox/_mount.py +++ b/buildstream/sandbox/_mount.py @@ -23,7 +23,7 @@ from contextlib import contextmanager, ExitStack from .. import utils from .._fuse import SafeHardlinks - +from ..storage import CasBasedDirectory # Mount() # @@ -35,6 +35,7 @@ class Mount(): # Getting _get_underlying_directory() here is acceptable as # we're part of the sandbox code. This will fail if our # directory is CAS-based. + assert not isinstance(sandbox.get_virtual_directory(), CasBasedDirectory) root_directory = sandbox.get_virtual_directory()._get_underlying_directory() self.mount_point = mount_point diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py index 88b697dca..104782800 100644 --- a/buildstream/sandbox/_sandboxbwrap.py +++ b/buildstream/sandbox/_sandboxbwrap.py @@ -32,7 +32,7 @@ from .._exceptions import SandboxError from .. import utils, _signals from ._mount import MountMap from . import Sandbox, SandboxFlags - +from ..storage import CasBasedDirectory # SandboxBwrap() # @@ -57,6 +57,9 @@ class SandboxBwrap(Sandbox): def run(self, command, flags, *, cwd=None, env=None): stdout, stderr = self._get_output() + # We cannot run directly from CAS-based directories at the moment. + assert not isinstance(self.get_virtual_directory(), CasBasedDirectory) + # Allowable access to underlying storage as we're part of the sandbox root_directory = self.get_virtual_directory()._get_underlying_directory() diff --git a/buildstream/sandbox/_sandboxremote.py b/buildstream/sandbox/_sandboxremote.py index 296b20351..572ee5f1b 100644 --- a/buildstream/sandbox/_sandboxremote.py +++ b/buildstream/sandbox/_sandboxremote.py @@ -172,6 +172,7 @@ class SandboxRemote(Sandbox): if isinstance(upload_vdir, FileBasedDirectory): # Make a new temporary directory to put source in upload_vdir = CasBasedDirectory(self._get_context(), ref=None) + assert not isinstance(self.get_virtual_directory(), CasBasedDirectory) upload_vdir.import_files(self.get_virtual_directory()._get_underlying_directory()) upload_vdir.recalculate_hash() |