You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/04/06 11:22:29 UTC

[GitHub] [ozone] sadanand48 commented on a change in pull request #2110: HDDS-4043. allow deletion from Trash directory without -skipTrash option

sadanand48 commented on a change in pull request #2110:
URL: https://github.com/apache/ozone/pull/2110#discussion_r607757357



##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashPolicyOzone.java
##########
@@ -118,6 +120,25 @@ public Runnable getEmptier() throws IOException {
         emptierInterval);
   }
 
+  @Override
+  public boolean moveToTrash(Path path) throws IOException {
+    this.fs.getFileStatus(path);
+    Path trashRoot = this.fs.getTrashRoot(path);
+    Path trashCurrent = new Path(trashRoot, CURRENT);

Review comment:
       Please remove `trashCurrent `variable as it is unused

##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashPolicyOzone.java
##########
@@ -118,6 +120,25 @@ public Runnable getEmptier() throws IOException {
         emptierInterval);
   }
 
+  @Override
+  public boolean moveToTrash(Path path) throws IOException {
+    this.fs.getFileStatus(path);
+    Path trashRoot = this.fs.getTrashRoot(path);
+    Path trashCurrent = new Path(trashRoot, CURRENT);
+
+    String key = path.toUri().getPath();
+    String trashRootKey = trashRoot.toUri().getPath();
+

Review comment:
       Can we please add a debug level log that prints values for` key` and `trashRootKey.`

##########
File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashPolicyOzone.java
##########
@@ -118,6 +120,25 @@ public Runnable getEmptier() throws IOException {
         emptierInterval);
   }
 
+  @Override
+  public boolean moveToTrash(Path path) throws IOException {
+    this.fs.getFileStatus(path);
+    Path trashRoot = this.fs.getTrashRoot(path);
+    Path trashCurrent = new Path(trashRoot, CURRENT);
+
+    String key = path.toUri().getPath();
+    String trashRootKey = trashRoot.toUri().getPath();
+
+    if (!OzoneFSUtils.isValidName(key)) {
+      throw new InvalidPathException("Invalid path Name " + key);
+    }
+
+    if (trashRootKey.startsWith(key) || key.startsWith(trashRootKey)) {

Review comment:
       I think only `key.startsWith(trashRootKey)` check would suffice. Do we need the OR condition?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org