ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r692047 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java src/tests/antunit/taskdefs/optional/unix/symlink-test.xml
Date Thu, 04 Sep 2008 14:28:06 GMT
Author: bodewig
Date: Thu Sep  4 07:28:04 2008
New Revision: 692047

URL: http://svn.apache.org/viewvc?rev=692047&view=rev
Log:
allow symlink to delete broken links.  Part of PR 41285.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
    ant/core/trunk/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=692047&r1=692046&r2=692047&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Sep  4 07:28:04 2008
@@ -91,6 +91,11 @@
    locale.
    Bugzilla Report 44659.
 
+ * <symlink action="delete"> used to fail if the link was broken (i.e.
+   pointing to a file or directory that no longer existed).  It will now
+   silently try to remove the link.
+   Bugzilla Report 41285.
+
 Fixed bugs:
 -----------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java?rev=692047&r1=692046&r2=692047&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java Thu Sep
 4 07:28:04 2008
@@ -391,7 +391,11 @@
      * rename the resource (breaking the link) and then deleting the link.
      * The resource is then returned to its original name inside a finally
      * block to ensure that the resource is unharmed even in the event of
-     * an exception.
+     * an exception.</p>
+     *
+     * <p>Since Ant 1.8.0 this method will try to delete the File object if
+     * it reports it wouldn't exist (as symlinks pointing nowhere usually do). 
+     * Prior version would throw a FileNotFoundException in that case.</p>
      *
      * @param linkfil    A <code>File</code> object of the symlink to delete.
      *
@@ -403,7 +407,8 @@
     public static void deleteSymlink(File linkfil)
         throws IOException {
         if (!linkfil.exists()) {
-            throw new FileNotFoundException("No such symlink: " + linkfil);
+            linkfil.delete();
+            return;
         }
         // find the resource of the existing link:
         File canfil = linkfil.getCanonicalFile();

Modified: ant/core/trunk/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml?rev=692047&r1=692046&r2=692047&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/optional/unix/symlink-test.xml Thu Sep  4 07:28:04
2008
@@ -62,4 +62,11 @@
         resource="${file_ref}"/>
   </target>
 
+  <target name="testDeleteOfBrokenLink" depends="init" if="unix">
+    <symlink link="${output}/link" resource="${file_ref}"/>
+    <delete file="${file_ref}"/>
+    <symlink link="${output}/link" action="delete"/>
+    <au:assertFileDoesntExist file="${output}/link"/>
+  </target>
+
 </project>



Mime
View raw message