You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/09/04 17:01:19 UTC

svn commit: r692082 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java

Author: bodewig
Date: Thu Sep  4 08:01:17 2008
New Revision: 692082

URL: http://svn.apache.org/viewvc?rev=692082&view=rev
Log:
don't try to re-rename a target that failed to be renamed in the first place.  Related to PR 41525.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/unix/Symlink.java

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=692082&r1=692081&r2=692082&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 08:01:17 2008
@@ -432,9 +432,11 @@
                                FILE_UTILS.removeLeadingPath(canfil, linkfil));
         }
 
+        boolean renamedTarget = false;
         try {
             try {
                 FILE_UTILS.rename(canfil, temp);
+                renamedTarget = true;
             } catch (IOException e) {
                 throw new IOException(
                     "Couldn't rename resource when attempting to delete "
@@ -446,6 +448,7 @@
                     + " (was it a real file? is this not a UNIX system?)");
             }
         } finally {
+            if (renamedTarget) {
             // return the resource to its original name:
             try {
                 FILE_UTILS.rename(temp, canfil);
@@ -455,6 +458,7 @@
                     + "\n THE RESOURCE'S NAME ON DISK HAS "
                     + "BEEN CHANGED BY THIS ERROR!\n");
             }
+            }
         }
     }