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-29 11:09:54 +0000
commitc7467e742f882346111d6ba1c312a7b72035f916 (patch)
tree63397f09d678613a45b28c4bf9b44389ebddc57d
parent44c5f2e6018fa284275cb6f91fba1b66479cbc37 (diff)
downloadbuildstream-c7467e742f882346111d6ba1c312a7b72035f916.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 d4147238e..a7ace324e 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.