ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaikiran <...@git.apache.org>
Subject [GitHub] ant pull request #49: [master branch] - Fix BZ-58683
Date Sun, 10 Dec 2017 08:25:00 GMT
Github user jaikiran commented on a diff in the pull request:

    https://github.com/apache/ant/pull/49#discussion_r155941095
  
    --- Diff: src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java ---
    @@ -207,26 +198,30 @@ public void recreate() throws BuildException {
             try {
                 if (fileSets.isEmpty()) {
                     handleError(
    -                    "File set identifying link file(s) required for action recreate");
    +                        "File set identifying link file(s) required for action recreate");
                     return;
                 }
    -            Properties links = loadLinks(fileSets);
    -
    -            for (String lnk : links.stringPropertyNames()) {
    -                String res = links.getProperty(lnk);
    -                // handle the case where lnk points to a directory (bug 25181)
    +            final Properties links = loadLinks(fileSets);
    +            for (final String lnk : links.stringPropertyNames()) {
    +                final String res = links.getProperty(lnk);
                     try {
    -                    File test = new File(lnk);
    -                    if (!SYMLINK_UTILS.isSymbolicLink(lnk)) {
    -                        doLink(res, lnk);
    -                    } else if (!test.getCanonicalPath().equals(
    -                        new File(res).getCanonicalPath())) {
    -                        SYMLINK_UTILS.deleteSymbolicLink(test, this);
    -                        doLink(res, lnk);
    -                    } // else lnk exists, do nothing
    -                } catch (IOException ioe) {
    -                    handleError("IO exception while creating link");
    +                    if (Files.isSymbolicLink(Paths.get(lnk)) &&
    +                            Paths.get(lnk).toFile().getCanonicalPath().equals(Paths.get(res).toFile().getCanonicalPath()))
{
    +                        // it's already a symlink and the symlink target is the same
    +                        // as the target noted in the properties file. So there's no
    +                        // need to recreate it
    +                        continue;
    +                    }
    +                } catch (IOException e) {
    +                    if (failonerror) {
    +                        throw new BuildException("Failed to recreate symlink " + lnk
+ " to target " + res, e);
    +                    }
    +                    // log and continue
    +                    log("Failed to recreate symlink " + lnk + " to target " + res, Project.MSG_INFO);
    +                    continue;
                     }
    +                // create the link
    +                this.doLink(res, lnk);
    --- End diff --
    
    You are right - the error message was incorrect. I have fixed that and updated the PR.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message