LuciferYang opened a new pull request, #8933:
URL: https://github.com/apache/hadoop/pull/8933

   ### Description of PR
   
   JIRA: https://issues.apache.org/jira/browse/HADOOP-20069
   
   `moveToTrash()` uses string prefix checks to decide whether a path is 
already in the trash and whether it contains the trash, without respecting path 
component boundaries:
   - `hadoop fs -rm -r /user/alice/.Trash_old` run by alice: the path starts 
with `/user/alice/.Trash`, so `moveToTrash()` returns false and `Delete` falls 
back to `fs.delete()`. The directory is deleted permanently.
   - `hadoop fs -rm -r /user/etl` run by etl_prod: `/user/etl_prod` starts with 
`/user/etl`, so the command fails with `Cannot move "/user/etl" to the trash, 
as it contains the trash`.
   
   Encryption zone and snapshot trash roots have the same problem 
(`/ez/.Trash/alice` and `/ez/.Trash/alice2`). This patch compares whole path 
components. Paths inside the trash, or containing it, are handled as before.
   
   ### How was this patch tested?
   
   Added two cases to `TestTrash` on a local file system whose home directory 
is under the test directory:
   - `testMoveToTrashTrashRootPrefixSibling`: `~/.Trashbackups` is moved to the 
trash, and a path inside `~/.Trash/Current` is still reported as already there.
   - `testMoveToTrashHomePrefixSibling`: `users/al` (home is `users/alice`) is 
moved to the trash, and moving the home directory still fails with `contains 
the trash`.
   
   Without the fix the first fails because `moveToTrash` returns false and the 
second fails with the `contains the trash` error.
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: Have the integration tests been executed and the 
endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   ### AI Tooling
   
   - [x] The PR includes the phrase "Contains content generated by Claude Opus".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Opus.
   


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