You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/12/16 15:48:00 UTC

[GitHub] [maven-clean-plugin] gnodet commented on a change in pull request #6: Add a fast clean option

gnodet commented on a change in pull request #6:
URL: https://github.com/apache/maven-clean-plugin/pull/6#discussion_r770665481



##########
File path: src/main/java/org/apache/maven/plugins/clean/Cleaner.java
##########
@@ -115,9 +124,63 @@ public void delete( File basedir, Selector selector, boolean followSymlinks, boo
 
         File file = followSymlinks ? basedir : basedir.getCanonicalFile();
 
+        if ( selector == null && !followSymlinks && fastFolder != null )
+        {
+            if ( fastDelete( file ) )
+            {
+                return;
+            }
+        }
+
         delete( file, "", selector, followSymlinks, failOnError, retryOnError );
     }
 
+    private boolean fastDelete( File baseDir )
+    {
+        fastFolder.mkdirs();
+        if ( fastFolder.isDirectory() )
+        {
+            try
+            {
+                File tmpDir = createTempDir( fastFolder );
+                File dstDir = new File( tmpDir, baseDir.getName() );
+                Files.move( baseDir.toPath(), dstDir.toPath(), StandardCopyOption.ATOMIC_MOVE );

Review comment:
       Yes, that's why the exception is caught if an atomic move can not be performed.  In which case, the usual deletion will be used.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org