sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [sling-org-apache-sling-feature-analyser] branch master updated: SLING-8153: delete content package extraction dir recursively.
Date Mon, 03 Dec 2018 12:18:47 GMT
This is an automated email from the ASF dual-hosted git repository.

pauls pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-analyser.git


The following commit(s) were added to refs/heads/master by this push:
     new 225d958  SLING-8153: delete content package extraction dir recursively.
225d958 is described below

commit 225d958d905f38f65acd5f27f7cbc93ae3bf05e0
Author: Karl Pauls <karlpauls@gmail.com>
AuthorDate: Mon Dec 3 13:18:39 2018 +0100

    SLING-8153: delete content package extraction dir recursively.
---
 .../scanner/impl/ContentPackageScanner.java        | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackageScanner.java
b/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackageScanner.java
index ce17c74..2b71815 100644
--- a/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackageScanner.java
+++ b/src/main/java/org/apache/sling/feature/scanner/impl/ContentPackageScanner.java
@@ -207,10 +207,28 @@ public class ContentPackageScanner {
                 i.lock();
             }
         } finally {
-            if ( tempDir.exists() ) {
-                tempDir.delete();
+            deleteRecursive(tempDir);
+        }
+    }
+
+    private boolean deleteRecursive(File file) {
+        if (file.isDirectory()) {
+            File[] childs = file.listFiles();
+            if (childs != null) {
+                for (File child : childs) {
+                    if (!deleteRecursive(child)) {
+                        return false;
+                    }
+                }
+                return file.delete();
+            }
+            else {
+                return false;
             }
         }
+        else {
+            return file.delete();
+        }
     }
 
     private ArtifactId extractArtifactId(final File tempDir, final File bundleFile)


Mime
View raw message