hemantk-12 commented on code in PR #7681:
URL: https://github.com/apache/ozone/pull/7681#discussion_r1964493597


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java:
##########
@@ -123,6 +133,24 @@ private boolean hasPermission(UserGroupInformation user) {
     }
   }
 
+  private void deleteContents(Path directory) throws IOException {
+    Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
+      @Override
+      public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) 
throws IOException {
+        Files.delete(file); // Delete file
+        return FileVisitResult.CONTINUE;
+      }
+
+      @Override
+      public FileVisitResult postVisitDirectory(Path dir, IOException exc) 
throws IOException {
+        if (!dir.equals(directory)) { // Skip deleting the root directory
+          Files.delete(dir);
+        }
+        return FileVisitResult.CONTINUE;
+      }
+    });
+  }
+

Review Comment:
   ```suggestion
   ```



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java:
##########
@@ -24,9 +24,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.file.FileVisitResult;

Review Comment:
   ```suggestion
   ```



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java:
##########
@@ -24,9 +24,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.file.FileVisitResult;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;

Review Comment:
   ```suggestion
   ```



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/DBCheckpointServlet.java:
##########
@@ -107,6 +110,13 @@ public void initialize(DBStore store, DBCheckpointMetrics 
metrics,
     }
     bootstrapTempData = Paths.get(tempData,
         "temp-bootstrap-data").toFile();
+    if (bootstrapTempData.exists()) {
+      try {
+        deleteContents(bootstrapTempData.toPath());

Review Comment:
   ```suggestion
           FileUtils.cleanDirectory(bootstrapTempData);
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to