From 3c931b0f1ba72ce655f1fe03295aff77b4bfcf38 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Thu, 12 Jun 2014 15:08:37 +0000
Subject: [PATCH] OPENDJ-1472 : File based changelog : optimize random seek in each log file CR-3727

---
 opends/src/server/org/opends/server/util/StaticUtils.java |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/opends/src/server/org/opends/server/util/StaticUtils.java b/opends/src/server/org/opends/server/util/StaticUtils.java
index bc27bed..b3cfa18 100644
--- a/opends/src/server/org/opends/server/util/StaticUtils.java
+++ b/opends/src/server/org/opends/server/util/StaticUtils.java
@@ -3463,32 +3463,36 @@
 
 
   /**
-   * Attempts to delete the specified file or directory.  If it is a directory,
+   * Attempts to delete the specified file or directory. If it is a directory,
    * then any files or subdirectories that it contains will be recursively
    * deleted as well.
    *
-   * @param  file  The file or directory to be removed.
-   *
-   * @return  <CODE>true</CODE> if the specified file and any subordinates are
-   *          all successfully removed, or <CODE>false</CODE> if at least one
-   *          element in the subtree could not be removed.
+   * @param file
+   *          The file or directory to be removed.
+   * @return {@code true} if the specified file and any subordinates are all
+   *         successfully removed, or {@code false} if at least one element in
+   *         the subtree could not be removed or file does not exists.
    */
   public static boolean recursiveDelete(File file)
   {
-    boolean successful = true;
-    if (file.isDirectory())
+    if (file.exists())
     {
-      File[] childList = file.listFiles();
-      if (childList != null)
+      boolean successful = true;
+      if (file.isDirectory())
       {
-        for (File f : childList)
+        File[] childList = file.listFiles();
+        if (childList != null)
         {
-          successful &= recursiveDelete(f);
+          for (File f : childList)
+          {
+            successful &= recursiveDelete(f);
+          }
         }
       }
-    }
 
-    return (successful & file.delete());
+      return (successful & file.delete());
+    }
+    return false;
   }
 
 

--
Gitblit v1.10.0