You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:47:09 UTC

[buildstream] 07/17: _stream.py: Convert to virtual directories.

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch jmac/virtual_directories_test
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ad87b9230748491d7c6eaa5d09cad096b1b13652
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Tue May 8 16:18:36 2018 +0100

    _stream.py: Convert to virtual directories.
---
 buildstream/_stream.py | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index a5eacac..b7848c3 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -390,13 +390,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:
@@ -920,22 +920,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):