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 2018/12/06 00:53:09 UTC

ant-ivy git commit: IVY-1594 Make sure we unlink an existing link, when retrieve task is enabled with symlink = true

Repository: ant-ivy
Updated Branches:
  refs/heads/master a7318cdb6 -> d1d956fc2


IVY-1594 Make sure we unlink an existing link, when retrieve task is enabled with symlink = true


Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/d1d956fc
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/d1d956fc
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/d1d956fc

Branch: refs/heads/master
Commit: d1d956fc2f9154e9e6452b54dd3f478d728e9fad
Parents: a7318cd
Author: Jaikiran Pai <ja...@apache.org>
Authored: Thu Dec 6 06:22:31 2018 +0530
Committer: Jaikiran Pai <ja...@apache.org>
Committed: Thu Dec 6 06:22:31 2018 +0530

----------------------------------------------------------------------
 src/java/org/apache/ivy/util/FileUtil.java | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d1d956fc/src/java/org/apache/ivy/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/util/FileUtil.java b/src/java/org/apache/ivy/util/FileUtil.java
index 2968708..9c780f2 100644
--- a/src/java/org/apache/ivy/util/FileUtil.java
+++ b/src/java/org/apache/ivy/util/FileUtil.java
@@ -85,9 +85,17 @@ public final class FileUtil {
                 return false;
             }
         } else {
-            // it's a directory being symlinked, make sure the "link" that is being
-            // created has the necessary parent directories in place before triggering
-            // symlink creation
+            // it's a directory being symlinked
+
+            // see if the directory represented by the "link" exists and is already a symbolic
+            // link. If it is and if we are asked to overwrite then we *only* break the link
+            // in preparation of symlink creation, later in this method
+            if (Files.isSymbolicLink(link.toPath()) && overwrite) {
+                Message.verbose("Un-linking existing symbolic link " + link + " during symlink creation, since overwrite=true");
+                Files.delete(link.toPath());
+            }
+            // make sure the "link" that is being created has the necessary parent directories
+            // in place before triggering symlink creation
             if (link.getParentFile() != null) {
                 link.getParentFile().mkdirs();
             }