summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-10-24 14:41:21 +0100
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-10-24 14:41:21 +0100
commitd5305d55f359dc02578bb0996871de681bac9b1a (patch)
treef2fa069c3e440d166efe7a61dd818c80585a81f4
parent4a9924b5f974751c3c18031068e8a4211b029683 (diff)
downloadbuildstream-d5305d55f359dc02578bb0996871de681bac9b1a.tar.gz
Don't forcbily create directories in _resolve in all cases
-rw-r--r--buildstream/storage/_casbaseddirectory.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py
index a418816da..f04a5f5c4 100644
--- a/buildstream/storage/_casbaseddirectory.py
+++ b/buildstream/storage/_casbaseddirectory.py
@@ -288,7 +288,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 {}"
@@ -381,7 +381,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
@@ -441,14 +441,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.