diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-10-30 12:19:23 +0000 |
---|---|---|
committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-10-30 12:19:23 +0000 |
commit | c9cfcf0291ed349797d27ec17d3824f90a8acd6c (patch) | |
tree | 94688c89e2be70a8b0889ffddbc457d8735d1b08 | |
parent | 545219dc9ea1212b2db53efdae6e76ac5d4fbfb8 (diff) | |
download | buildstream-c9cfcf0291ed349797d27ec17d3824f90a8acd6c.tar.gz |
_casbaseddirectory: Restructure resolve to make it a bit more logical
-rw-r--r-- | buildstream/storage/_casbaseddirectory.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/buildstream/storage/_casbaseddirectory.py b/buildstream/storage/_casbaseddirectory.py index a868c526f..cd066495c 100644 --- a/buildstream/storage/_casbaseddirectory.py +++ b/buildstream/storage/_casbaseddirectory.py @@ -365,26 +365,32 @@ class CasBasedDirectory(Directory): if isinstance(f, CasBasedDirectory): directory = f - + elif isinstance(f, remote_execution_pb2.FileNode): + # F is a file + if components: + # We have components still to resolve, but one of the path components + # is a file. + if force_create: + self.delete_entry(c) + directory = directory.descend(c, create=True) + else: + return f # TODO: Why return f? We've got components left and hit a file; this should be an error. + #raise VirtualDirectoryError("Reached a file called {} while trying to resolve a symlink; cannot proceed".format(c)) + else: + # It's a file, but there's no components left, so just return that. + return f else: - # This is a file or None (i.e. broken symlink) - if f is None and force_create: + # f is none, which covers many cases + if force_create: directory = directory.descend(c, create=True) - elif components and force_create: - # Oh dear. We have components left to resolve, but the one we're trying to resolve points to a file. - print("Trying to resolve {}, but found {} was a file.".format(symlink.target, c)) - self.delete_entry(c) - directory = directory.descend(c, create=True) - #raise VirtualDirectoryError("Reached a file called {} while trying to resolve a symlink; cannot proceed".format(c)) else: - return f + return None else: if force_create: directory = directory.descend(c, create=True) else: return None - - # Shouldn't get here. + # You can only exit the while loop with a return, so you shouldn't be here. def _check_replacement(self, name, path_prefix, fileListResult): |