diff options
author | 2015-10-13 08:53:54 +0000 | |
---|---|---|
committer | 2015-10-13 08:57:25 +0000 | |
commit | b10157f88e8c2903d73712f0d5887b8b204d2bd9 (patch) | |
tree | bff660209fea7b27839362df449dc35cc10609f4 /src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java | |
parent | 829d118bb5621f5e908e96094fa15b8669dced1c (diff) |
Make the /... recursive package target wildcard traverse symlinks.
This works because we resolve the FileValue for every directory found during the traversal, therefore, symlink cycles and symlink structures giving rise to infinite directory trees are handled correctly (that is to say, the same way as they are handled during globbing)
Fixes #274.
--
MOS_MIGRATED_REVID=105290852
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java index 1927851d40..b33f78c3d9 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/RecursiveDirectoryTraversalFunction.java @@ -130,11 +130,6 @@ abstract class RecursiveDirectoryTraversalFunction return getEmptyReturn(); } - if (fileValue.isSymlink()) { - // We do not follow directory symlinks. It prevents symlink loops. - return getEmptyReturn(); - } - PackageIdentifier packageId = PackageIdentifier.create( recursivePkgKey.getRepository(), rootRelativePath); PackageLookupValue pkgLookupValue; @@ -213,8 +208,15 @@ abstract class RecursiveDirectoryTraversalFunction List<SkyKey> childDeps = Lists.newArrayList(); for (Dirent dirent : dirValue.getDirents()) { - if (dirent.getType() != Type.DIRECTORY) { - // Non-directories can never host packages, and we do not follow symlinks (see above). + if (dirent.getType() != Type.DIRECTORY && dirent.getType() != Type.SYMLINK) { + // Non-directories can never host packages. Symlinks to non-directories are weeded out at + // the next level of recursion when we check if its FileValue is a directory. This is slower + // if there are a lot of symlinks in the tree, but faster if there are only a few, which is + // the case most of the time. + // + // We are not afraid of weird symlink structure here: cyclical ones are diagnosed by + // FileValue and ones that give rise to infinite directory trees work just like they do with + // globbing: they work until a certain level of nesting, after which they fail. continue; } String basename = dirent.getName(); |