slfan1989 commented on code in PR #8933:
URL: https://github.com/apache/hadoop/pull/8933#discussion_r4504630409


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java:
##########
@@ -121,6 +121,18 @@ private Path makeTrashRelativePath(Path basePath, Path 
rmFilePath) {
     return Path.mergePaths(basePath, rmFilePath);
   }
 
+  /**
+   * @return true if {@code ancestor} is {@code path} or one of its ancestors,
+   *         comparing whole path components: "/user/al" is not an ancestor
+   *         of "/user/alice".
+   */
+  private static boolean isAncestorOf(Path ancestor, Path path) {
+    String a = ancestor.toString();

Review Comment:
   Could we compare the URI path components here? 
   
   `Path.toString()` includes the fragment, but `RawLocalFileSystem` ignores it 
when resolving the file. 
   
   I reproduced this with a `Path` constructed from a URI ending in 
`.Trash#alias`: before the patch, `moveToTrash()` returns `false`; with this 
patch, it tries to move `.Trash` into its own `Current` directory and throws. 
   
   Could we add a regression test for this case?



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