You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 08:06:41 UTC
[buildstream] 05/41: _stream.py: Convert to virtual directories.
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch jmac/googlecas_and_virtual_directories_1
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit def52043236c4b96ccdc66e199d83041c161edfe
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 cdef690..0c46ab3 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:
@@ -929,22 +929,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):