Skip to content

Commit 591acf2

Browse files
committed
add back follow links
1 parent 7e302f9 commit 591acf2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/cleanroommc/groovyscript/sandbox/SandboxData.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.io.IOException;
1212
import java.net.MalformedURLException;
1313
import java.net.URL;
14+
import java.nio.file.FileVisitOption;
1415
import java.nio.file.Files;
1516
import java.nio.file.Path;
1617
import java.util.ArrayList;
@@ -24,6 +25,9 @@
2425
*/
2526
public class SandboxData {
2627

28+
private static final FileVisitOption[] FOLLOW_LINKS = {FileVisitOption.FOLLOW_LINKS};
29+
private static final FileVisitOption[] NO_VISIT_OPTIONS = {};
30+
2731
public static final String[] GROOVY_SUFFIXES = {
2832
".groovy", ".gvy", ".gy", ".gsh"
2933
};
@@ -131,7 +135,7 @@ public static String getRelativePath(String path) {
131135
return FileUtil.relativize(getScriptPath(), path);
132136
}
133137

134-
static Collection<File> getSortedFilesOf(File root, Collection<String> paths) {
138+
static Collection<File> getSortedFilesOf(File root, Collection<String> paths, boolean debug) {
135139
Object2IntLinkedOpenHashMap<File> files = new Object2IntLinkedOpenHashMap<>();
136140
String separator = File.separatorChar == '\\' ? "\\\\" : File.separator;
137141

@@ -143,7 +147,7 @@ static Collection<File> getSortedFilesOf(File root, Collection<String> paths) {
143147
// if we are looking at a specific file, we don't want that to be overridden.
144148
// otherwise, we want to use the specificity based on the number of file separators.
145149
int pathSize = StringUtils.countMatches(path, separator);
146-
try (Stream<Path> stream = Files.walk(rootFile.toPath())) {
150+
try (Stream<Path> stream = Files.walk(rootFile.toPath(), debug ? FOLLOW_LINKS : NO_VISIT_OPTIONS)) {
147151
stream.filter(path1 -> isGroovyFile(path1.toString()))
148152
.map(Path::toFile)
149153
//.filter(Preprocessor::validatePreprocessors)

0 commit comments

Comments
 (0)