diff --git a/WHATSNEW b/WHATSNEW index 887822072..82d1cde4e 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -68,6 +68,13 @@ Fixed bugs: read-only file as expected but also remove the existing file. Bugzilla Report 53095 + * would remove symbolic + links to not-included files. It will still delete symlinks to + directories that would have been followed even if they are not + explicitly included. exclude-Patterns can still be used to + preserve symbolic links. + Bugzilla Report 53959 + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java index 92d97dec0..9049cc6c5 100644 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -1012,9 +1012,7 @@ public class DirectoryScanner if (myfile != null && myfile.exists()) { if (!followSymlinks && currentPath.isSymlink(basedir)) { - if (!isExcluded(currentPath)) { - notFollowedSymlinks.add(myfile.getAbsolutePath()); - } + accountForNotFollowedSymlink(currentPath, myfile); continue; } if (myfile.isDirectory()) { @@ -1226,9 +1224,7 @@ public class DirectoryScanner File file = new File(dir, newfiles[i]); (file.isDirectory() ? dirsExcluded : filesExcluded).addElement(name); - if (!isExcluded(name)) { - notFollowedSymlinks.add(file.getAbsolutePath()); - } + accountForNotFollowedSymlink(name, file); } else { noLinks.add(newfiles[i]); } @@ -1329,6 +1325,19 @@ public class DirectoryScanner } } + private void accountForNotFollowedSymlink(String name, File file) { + accountForNotFollowedSymlink(new TokenizedPath(name), file); + } + + private void accountForNotFollowedSymlink(TokenizedPath name, File file) { + if (!isExcluded(name) && + (isIncluded(name) + || (file.isDirectory() && couldHoldIncluded(name) + && !contentsExcluded(name)))) { + notFollowedSymlinks.add(file.getAbsolutePath()); + } + } + private void processIncluded(TokenizedPath path, File file, Vector inc, Vector exc, Vector des) { diff --git a/src/tests/antunit/taskdefs/delete-and-symlinks-test.xml b/src/tests/antunit/taskdefs/delete-and-symlinks-test.xml index c3791af13..ac789940f 100644 --- a/src/tests/antunit/taskdefs/delete-and-symlinks-test.xml +++ b/src/tests/antunit/taskdefs/delete-and-symlinks-test.xml @@ -31,26 +31,54 @@ - + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + +