Browse Source

BZ-58683 Explicitly use LinkOption.NOFOLLOW_LINKS while checking for existence of a file

master
Jaikiran Pai 7 years ago
parent
commit
454e4e2f19
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java

+ 2
- 1
src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java View File

@@ -37,6 +37,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -440,7 +441,7 @@ public class Symlink extends DispatchTask {
private void doLink(String res, String lnk) throws BuildException {
final Path link = Paths.get(lnk);
final Path target = Paths.get(res);
final boolean alreadyExists = Files.exists(link);
final boolean alreadyExists = Files.exists(link, LinkOption.NOFOLLOW_LINKS);
if (!alreadyExists) {
// if the path (at which the link is expected to be created) isn't already present
// then we just go ahead and attempt to symlink


Loading…
Cancel
Save