You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2017/12/12 05:20:22 UTC
ant git commit: BZ-58683 Don't break the semantics that were
introduced as part of BZ-43426 i.e. allow overwritting (if the attribute is
set to true) of existing non-symlink files with a symlink
Repository: ant
Updated Branches:
refs/heads/master 7f1e7628b -> b3c7d5dc4
BZ-58683 Don't break the semantics that were introduced as part of BZ-43426 i.e. allow overwritting (if the attribute is set to true) of existing non-symlink files with a symlink
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/b3c7d5dc
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/b3c7d5dc
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/b3c7d5dc
Branch: refs/heads/master
Commit: b3c7d5dc451960986a94d24785a2c1d24b0b0d6a
Parents: 7f1e762
Author: Jaikiran Pai <ja...@gmail.com>
Authored: Tue Dec 12 10:43:53 2017 +0530
Committer: Jaikiran Pai <ja...@gmail.com>
Committed: Tue Dec 12 10:46:15 2017 +0530
----------------------------------------------------------------------
.../ant/taskdefs/optional/unix/Symlink.java | 23 +++++---------------
1 file changed, 6 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/b3c7d5dc/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
index a14bf47..8a27212 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
@@ -461,24 +461,12 @@ public class Symlink extends DispatchTask {
}
// we have been asked to overwrite, so we now do the necessary steps
- // initiate a deletion *only* if the path is a symlink, else we fail with error
- if (!Files.isSymbolicLink(link)) {
- final String errMessage = "Cannot overwrite " + lnk + " since the path already exists and isn't a symlink";
- if (failonerror) {
- throw new BuildException(errMessage);
- }
- // log and return
- log(errMessage, Project.MSG_INFO);
+ // initiate a deletion of the existing file
+ final boolean existingFileDeleted = link.toFile().delete();
+ if (!existingFileDeleted) {
+ handleError("Deletion of file at " + lnk + " failed, while trying to overwrite it with a symlink");
return;
}
- // it's a symlink, so we delete the *link* first
- try {
- deleteSymLink(link);
- } catch (IOException e) {
- // our deletion attempt failed, just log it and try to create the symlink
- // anyway, since we have been asked to overwrite
- log("Failed to delete existing symlink at " + lnk, e, Project.MSG_DEBUG);
- }
try {
Files.createSymbolicLink(link, target);
} catch (IOException e) {
@@ -587,7 +575,8 @@ public class Symlink extends DispatchTask {
// Not clearing/updating that cache results in this deleted (and later recreated) symlink
// to point to a wrong/outdated target for a few seconds (30 seconds is the time the JRE
// maintains the cache entries for). All this is implementation detail of the JRE and
- // probably a bug, but given that it affects our tests (SymlinkTest#testRecreate consistently fails
+ // is a JRE bug http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-December/050540.html,
+ // but given that it affects our tests (SymlinkTest#testRecreate consistently fails
// on MacOS/Unix) as well as the Symlink task, it makes sense to use this API instead of
// the Files#delete(Path) API
final boolean deleted = path.toFile().delete();