Author: xavier
Date: Wed Jun 25 07:40:30 2008
New Revision: 671574

URL: http://svn.apache.org/viewvc?rev=671574&view=rev
Log:
handle case where transaction destination directory already exists (which makes 
the commit impossible) (probably related to IVY-733)

Modified:
    
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java

Modified: 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
URL: 
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java?rev=671574&r1=671573&r2=671574&view=diff
==============================================================================
--- 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
 (original)
+++ 
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
 Wed Jun 25 07:40:30 2008
@@ -136,6 +136,11 @@
             if (!isTransactionStarted()) {
                 throw new IllegalStateException("no current transaction!");
             }
+            if (transactionDestDir.exists()) {
+                throw new IOException(
+                    "impossible to commit transaction: transaction destination 
directory "
+                    + "already exists: " + transactionDestDir);
+            }
             try {
                 getFileRepository().move(transactionTempDir, 
transactionDestDir);
                 
@@ -172,10 +177,16 @@
                 unsupportedTransaction("overwrite transaction not supported 
yet");
             } else {
                 initTransaction(module);
-                Message.verbose(
-                    "\tstarting transaction: publish during transaction will 
be done in \n\t\t" 
-                    + transactionTempDir 
-                    + "\n\t\tand on commit moved to \n\t\t" + 
transactionDestDir);
+                if (transactionDestDir.exists()) {
+                    unsupportedTransaction(
+                        "transaction destination directory already exists: " + 
transactionDestDir);
+                    closeTransaction();
+                } else {
+                    Message.verbose(
+                        "\tstarting transaction: publish during transaction 
will be done in \n\t\t" 
+                        + transactionTempDir 
+                        + "\n\t\tand on commit moved to \n\t\t" + 
transactionDestDir);
+                }
             }
         }
     }


Reply via email to