You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:13:40 UTC
[buildstream] 19/43: Don't forcbily create directories in _resolve
in all cases
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch jmac/cas_to_cas_oct_v2
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit c7467e742f882346111d6ba1c312a7b72035f916
Author: Jim MacArthur <ji...@codethink.co.uk>
AuthorDate: Wed Oct 24 14:41:21 2018 +0100
Don't forcbily create directories in _resolve in all cases
---
buildstream/storage/_casbaseddirectory.py | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py
index d414723..a7ace32 100644
--- a/buildstream/storage/_casbaseddirectory.py
+++ b/buildstream/storage/_casbaseddirectory.py
@@ -289,7 +289,7 @@ class CasBasedDirectory(Directory):
return entry.descend(subdirectory_spec[1:], create)
else:
# May be a symlink
- target = self._resolve(subdirectory_spec[0])
+ target = self._resolve(subdirectory_spec[0], force_create=create)
if isinstance(target, CasBasedDirectory):
return target
error = "Cannot descend into {}, which is a '{}' in the directory {}"
@@ -382,7 +382,7 @@ class CasBasedDirectory(Directory):
return directory
- def _resolve(self, name, absolute_symlinks_resolve=True):
+ def _resolve(self, name, absolute_symlinks_resolve=True, force_create=False):
""" Resolves any name to an object. If the name points to a symlink in
this directory, it returns the thing it points to,
recursively. Returns a CasBasedDirectory, FileNode or
@@ -442,14 +442,21 @@ class CasBasedDirectory(Directory):
else:
# This is a file or None (i.e. broken symlink)
print(" resolving {}: file/broken link".format(c))
- if components:
+ if f is None and force_create:
+ print("Creating target of broken link {}".format(c))
+ return directory.descend(c, create=True)
+ elif components:
# Oh dear. We have components left to resolve, but the one we're trying to resolve points to a file.
raise VirtualDirectoryError("Reached a file called {} while trying to resolve a symlink; cannot proceed".format(c))
else:
return f
else:
- print(" resolving {}: Broken symlink".format(c))
- return None
+ print(" resolving {}: Non-existent file; must be from a broken symlink.".format(c))
+ if force_create:
+ print("Creating target of broken link {} (2)".format(c))
+ return directory.descend(c, create=True)
+ else:
+ return None
# Shouldn't get here.