maobaolong commented on pull request #2437:
URL: https://github.com/apache/hadoop/pull/2437#issuecomment-722902960
@ferhui @Hexiaoqiao Thanks for the simplify suggestion, It make the code
more clear.
```java
private static boolean deleteAllowed(final INodesInPath iip) {
if (iip.length() < 1 || iip.getLastINode() == null) {
if (NameNode.stateChangeLog.isDebugEnabled()) {
NameNode.stateChangeLog.debug(
"DIR* FSDirectory.unprotectedDelete: failed to remove "
+ iip.getPath() + " because it does not exist");
}
return false;
} else if (iip.length() == 1) { // src is the root
NameNode.stateChangeLog.warn(
"DIR* FSDirectory.unprotectedDelete: failed to remove " +
iip.getPath() + " because the root is not allowed to be
deleted");
return false;
}
return true;
}
```
As the `deleteAllowed` return false means this call don't allowed to delete,
so I think it make sense to record `allowed = false` to auditlog.
And when `iip.length() < 1 || iip.getLastINode() == null` or `iip.length()
== 1` make `deleteAllowed` return `false`, so for the current deleteAllowed`
method implementation, ` iip.getLastINode() == null` should make record
`allowed = false` to auditlog.
After an overlook at the delete flow, `iip.getLastINode()` might not be
`null`.
I push a new commit to simplify the test code, Please take another look,
thanks.
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]