[Arakhnę-Dev] [316] * Avoid infinite loop when deleting a file tree.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 316
Author:   galland
Date:     2011-11-05 14:31:42 +0100 (Sat, 05 Nov 2011)
Log Message:
-----------
* Avoid infinite loop when deleting a file tree.

Modified Paths:
--------------
    trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java

Modified: trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java
===================================================================
--- trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java	2011-11-05 13:20:01 UTC (rev 315)
+++ trunk/maventools/src/main/java/org/arakhne/maven/AbstractArakhneMojo.java	2011-11-05 13:31:42 UTC (rev 316)
@@ -244,16 +244,19 @@
 			File[] children;
 			while (!candidates.isEmpty()) {
 				f = candidates.getFirst();
+				debug("Scanning: "+f); //$NON-NLS-1$
 				if (f.isDirectory()) {
 					children = f.listFiles();
-					if (children!=null && children.length>1) {
+					if (children!=null && children.length>0) {
 						// Non empty directory
 						for(File c : children) {
+							debug("Discovering: "+c); //$NON-NLS-1$
 							candidates.push(c);
 						}
 					}
 					else {
 						// empty directory
+						debug("Deleting: "+f); //$NON-NLS-1$
 						candidates.removeFirst();
 						f.delete();
 					}
@@ -261,9 +264,13 @@
 				else {
 					// not a directory
 					candidates.removeFirst();
-					if (f.exists()) f.delete();
+					if (f.exists()) {
+						debug("Deleting: "+f); //$NON-NLS-1$
+						f.delete();
+					}
 				}
 			}
+			debug("Deletion done"); //$NON-NLS-1$
 		}
 	}
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/