summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-09-24 15:06:29 +0100
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-09-24 15:06:29 +0100
commita7d1d169995856d636fde0a46a2deade8418afa3 (patch)
treec82b061ce74664ab7304039ce5154f325cd4ef2a
parent252aba3508b16380e8b4100fb7881a8942285503 (diff)
downloadbuildstream-a7d1d169995856d636fde0a46a2deade8418afa3.tar.gz
_casbaseddirectory.py: Descend through symlinks to directories, too
-rw-r--r--buildstream/storage/_casbaseddirectory.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py
index 87612bb96..1912a89b4 100644
--- a/buildstream/storage/_casbaseddirectory.py
+++ b/buildstream/storage/_casbaseddirectory.py
@@ -250,13 +250,17 @@ class CasBasedDirectory(Directory):
return self
if subdirectory_spec[0] in self.index:
- entry = self.index[subdirectory_spec[0]].buildstream_object
- if isinstance(entry, CasBasedDirectory):
- return entry.descend(subdirectory_spec[1:], create)
+ buildstream_object = self.index[subdirectory_spec[0]].buildstream_object
+ pb_object = self.index[subdirectory_spec[0]].pb_object
+ if isinstance(buildstream_object, CasBasedDirectory):
+ return buildstream_object.descend(subdirectory_spec[1:], create)
+ elif isinstance(pb_object, remote_execution_pb2.SymlinkNode):
+ target = self._resolve_symlink_or_directory(subdirectory_spec[0])
+ return target.descend(subdirectory_spec[1:], create)
else:
error = "Cannot descend into {}, which is a '{}' in the directory {}"
raise VirtualDirectoryError(error.format(subdirectory_spec[0],
- type(entry).__name__,
+ type(self.index[subdirectory_spec[0]].pb_object).__name__,
self))
else:
if create:
@@ -308,6 +312,10 @@ class CasBasedDirectory(Directory):
directory = directory.descend(c, create=True)
return directory
+ def symlink_target_is_directory(self, symlink_node):
+ x = self._resolve_symlink_or_directory(symlink_node.name)
+ return isinstance(x, CasBasedDirectory)
+
def _check_replacement(self, name, path_prefix, fileListResult):
""" Checks whether 'name' exists, and if so, whether we can overwrite it.
If we can, add the name to 'overwritten_files' and delete the existing entry.
@@ -413,7 +421,7 @@ class CasBasedDirectory(Directory):
# Now strip off the first directory name and import files recursively.
subcomponents = CasBasedDirectory.files_in_subdir(files, dirname)
self.create_directory(dirname)
- dest_subdir = self.descend(dirname)
+ dest_subdir = self.descend(dirname, create=True)
src_subdir = source_directory.descend(dirname)
import_result = dest_subdir._partial_import_cas_into_cas(src_subdir, subcomponents,
path_prefix=fullname, file_list_required=file_list_required)