Behavior seems to have changed from 2.6, use
FileVisitOption.FOLLOW_LINKS to remedy.
MODIFY
src/main/java/org/apache/commons/io/file/PathUtils.java
src/main/java/org/apache/commons/io/file/PathUtils.java
@@ -153,7 +153,22 @@ private RelativeSortedPaths(final Path dir1, final Path dir2, final int maxDepth
* @throws IOException if an I/O error is thrown by a visitor method.
*/
public static PathCounters cleanDirectory(final Path directory) throws IOException {
- return visitFileTree(CleaningPathVisitor.withLongCounters(), directory).getPathCounters();
+ return cleanDirectory(directory, FileVisitOption.FOLLOW_LINKS);
+ }
+
+ /**
+ * Cleans a directory including sub-directories without deleting directories.
+ *
+ * @param directory directory to clean.
+ * @param fileVisitOptions See {@link Files#walkFileTree(Path,Set,int,FileVisitor)}.
+ * @return The visitation path counters.
+ * @throws IOException if an I/O error is thrown by a visitor method.
+ * @since 2.9
+ */
+ public static PathCounters cleanDirectory(final Path directory, final FileVisitOption... fileVisitOptions)
+ throws IOException {
+ return visitFileTree(CleaningPathVisitor.withLongCounters(), directory, toFileVisitOptionSet(fileVisitOptions),
+ Integer.MAX_VALUE).getPathCounters();
}
/**
@@ -262,6 +277,18 @@ public static PathCounters delete(final Path path) throws IOException {
* @throws IOException if an I/O error is thrown by a visitor method.
*/
public static PathCounters deleteDirectory(final Path directory) throws IOException {
+ return deleteDirectory(directory, FileVisitOption.FOLLOW_LINKS);
+ }
+
+ /**
+ * Deletes a directory including sub-directories.
+ *
+ * @param directory directory to delete.
+ * @param fileVisitOptions See {@link Files#walkFileTree(Path,Set,int,FileVisitor)}.
+ * @return The visitor used to delete the given directory.
+ * @throws IOException if an I/O error is thrown by a visitor method.
+ */
+ public static PathCounters deleteDirectory(final Path directory, final FileVisitOption... fileVisitOptions) throws IOException {
return visitFileTree(DeletingPathVisitor.withLongCounters(), directory).getPathCounters();
}

Behavior seems to have changed from 2.6, use
FileVisitOption.FOLLOW_LINKS to remedy.