Merge "idegen: Handle symbolic link that targets to current or parent directory" am: d6c9ae2806
Original change: https://android-review.googlesource.com/c/platform/development/+/2203929 Change-Id: I539afd4eaa4a467e509433109856749c6f82c5bd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -18,6 +18,8 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -153,6 +155,17 @@ public class Configuration {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Files.isSymbolicLink(file.toPath())) {
|
||||||
|
Path target = Files.readSymbolicLink(file.toPath()).normalize();
|
||||||
|
if (target.startsWith("") || target.startsWith(".")
|
||||||
|
|| target.startsWith("..")) {
|
||||||
|
// Don't recurse symbolic link that targets to parent
|
||||||
|
// or current directory.
|
||||||
|
Log.debug("Skipped: " + path);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
// Traverse nested directories.
|
// Traverse nested directories.
|
||||||
if (excludes.exclude(path)) {
|
if (excludes.exclude(path)) {
|
||||||
@@ -216,8 +229,7 @@ public class Configuration {
|
|||||||
* found.
|
* found.
|
||||||
*/
|
*/
|
||||||
private static String parsePackageName(File file) throws IOException {
|
private static String parsePackageName(File file) throws IOException {
|
||||||
BufferedReader in = new BufferedReader(new FileReader(file));
|
try (BufferedReader in = new BufferedReader(new FileReader(file))) {
|
||||||
try {
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String trimmed = line.trim();
|
String trimmed = line.trim();
|
||||||
@@ -230,8 +242,6 @@ public class Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
|
||||||
in.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user