felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1352147 - in /felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin: DeploymentAdminImpl.java Utils.java
Date Wed, 20 Jun 2012 15:11:45 GMT
Author: marrs
Date: Wed Jun 20 15:11:45 2012
New Revision: 1352147

URL: http://svn.apache.org/viewvc?rev=1352147&view=rev
Log:
Removed an "unsafe" delete method from Utils and replaced invocations to it with a "safe"
delete method (one that *does* check the return code from File.delete()).

Modified:
    felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java
    felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Utils.java

Modified: felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java?rev=1352147&r1=1352146&r2=1352147&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java
(original)
+++ felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/DeploymentAdminImpl.java
Wed Jun 20 15:11:45 2012
@@ -272,7 +272,10 @@ public class DeploymentAdminImpl impleme
         }
         finally {
             if (tempPackage != null) {
-                Utils.delete(tempPackage);
+                if (!Utils.delete(tempPackage, true)) {
+                	m_log.log(LogService.LOG_ERROR, "Could not delete temporary deployment package
from disk");
+                	succeeded = false;
+                }
             }
         	if (source != null) {
         	    sendCompleteEvent(source, target, succeeded);
@@ -353,7 +356,10 @@ public class DeploymentAdminImpl impleme
             }
 
             File targetPackage = m_context.getDataFile(PACKAGE_DIR + File.separator + source.getName());
-            Utils.delete(targetPackage);
+            if (!Utils.delete(targetPackage, true)) {
+            	m_log.log(LogService.LOG_ERROR, "Could not delete deployment package from disk");
+            	throw new DeploymentException(DeploymentException.CODE_OTHER_ERROR, "Could not
delete deployment package from disk");
+            }
             
             m_packages.remove(dp.getName());
 

Modified: felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Utils.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Utils.java?rev=1352147&r1=1352146&r2=1352147&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Utils.java
(original)
+++ felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/Utils.java
Wed Jun 20 15:11:45 2012
@@ -106,18 +106,6 @@ public class Utils {
         return result;
     }
 
-
-    public static void delete(File target) {
-        // TODO merge with #delete(File, boolean)?!
-        if (target.isDirectory()) {
-            File[] childs = target.listFiles();
-            for (int i = 0; i < childs.length; i++) {
-                delete(childs[i]);
-            }
-        }
-        target.delete();
-    }
-
     public static boolean rename(File from, File to) {
         if (!from.renameTo(to)) {
             if (copy(from, to)) {
@@ -132,7 +120,7 @@ public class Utils {
         return true;
     }
 
-    private static boolean delete(File root, boolean deleteRoot) {
+    public static boolean delete(File root, boolean deleteRoot) {
         boolean result = true;
         if (root.isDirectory()) {
             File[] files = root.listFiles();



Mime
View raw message