diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-05-08 16:18:36 +0100 |
---|---|---|
committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-06-12 17:28:33 +0100 |
commit | 7d1043667002ca1c4c16e21c1848889bc12aefab (patch) | |
tree | 9fa31c07f40245a77818caff8bedf3c23f058b42 | |
parent | 54cd134f94a05643b39c3be0b9971b50b4309e20 (diff) | |
download | buildstream-7d1043667002ca1c4c16e21c1848889bc12aefab.tar.gz |
_stream.py: Convert to virtual directories.
-rw-r--r-- | buildstream/_stream.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/buildstream/_stream.py b/buildstream/_stream.py index f2806b4c8..2b6a2db7b 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -388,13 +388,13 @@ class Stream(): with target._prepare_sandbox(Scope.RUN, None, integrate=integrate) as sandbox: # Copy or move the sandbox to the target directory - sandbox_root = sandbox.get_directory() + sandbox_vroot = sandbox.get_virtual_directory() with target.timed_activity("Checking out files in {}".format(directory)): try: if hardlinks: - self._checkout_hardlinks(sandbox_root, directory) + self._checkout_hardlinks(sandbox_vroot, directory) else: - utils.copy_files(sandbox_root, directory) + sandbox_vroot.export_files(directory) except OSError as e: raise StreamError("Failed to checkout files: {}".format(e)) from e except BstError as e: @@ -967,22 +967,19 @@ class Stream(): # Helper function for checkout() # - def _checkout_hardlinks(self, sandbox_root, directory): + def _checkout_hardlinks(self, sandbox_vroot, directory): try: removed = utils.safe_remove(directory) except OSError as e: raise StreamError("Failed to remove checkout directory: {}".format(e)) from e if removed: - # Try a simple rename of the sandbox root; if that - # doesnt cut it, then do the regular link files code path - try: - os.rename(sandbox_root, directory) - except OSError: - os.makedirs(directory, exist_ok=True) - utils.link_files(sandbox_root, directory) + # TODO: Direct rename is no longer possible with the new Virtual Directory interface. + # See what options there are to restore it. + os.makedirs(directory, exist_ok=True) + sandbox_vroot.export_files(directory, can_link=True) else: - utils.link_files(sandbox_root, directory) + sandbox_vroot.export_files(directory, can_link=True) # Write the element build script to the given directory def _write_element_script(self, directory, element): |