ashishkumar50 commented on code in PR #4675:
URL: https://github.com/apache/ozone/pull/4675#discussion_r1188485986


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/DeleteKeyHandler.java:
##########
@@ -45,6 +64,81 @@ protected void execute(OzoneClient client, OzoneAddress 
address)
 
     OzoneVolume vol = client.getObjectStore().getVolume(volumeName);
     OzoneBucket bucket = vol.getBucket(bucketName);
-    bucket.deleteKey(keyName);
+
+    float hadoopTrashInterval = getConf().getFloat(
+        FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT);
+
+    long trashInterval =
+            (long) (getConf().getFloat(
+                    OMConfigKeys.OZONE_FS_TRASH_INTERVAL_KEY,
+                    hadoopTrashInterval) * 10000);
+
+    // If Bucket layout is FSO and Trash is enabled
+    // In this case during delete operation move key to trash
+    if (bucket.getBucketLayout().isFileSystemOptimized() && trashInterval > 0
+        && !skipTrash && !keyName.contains(".Trash")) {
+
+      keyName = OzoneFSUtils.removeTrailingSlashIfNeeded(keyName);
+      try {
+        // Check if key exists in Ozone
+        OzoneKeyDetails key = bucket.getKey(keyName);
+        if (key == null) {
+          out().printf("Key not found %s", keyName);
+          return;
+        }
+        // Check whether directory is empty or not
+        Iterator<? extends OzoneKey> ozoneKeyIterator =
+            bucket.listKeys(keyName, keyName);

Review Comment:
   Handled the change.



-- 
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