arp7 commented on a change in pull request #1196:
URL: https://github.com/apache/hadoop-ozone/pull/1196#discussion_r453774238
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCreateRequest.java
##########
@@ -221,8 +233,45 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager,
OmBucketInfo bucketInfo = omMetadataManager.getBucketTable().get(
omMetadataManager.getBucketKey(volumeName, bucketName));
+ boolean createIntermediateDir =
+ ozoneManager.getConfiguration().getBoolean(
+ OZONE_OM_CREATE_INTERMEDIATE_DIRECTORY,
+ OZONE_OM_CREATE_INTERMEDIATE_DIRECTORY_DEFAULT);
+
+ // If FILE_EXISTS we just override like how we used to do for Key Create.
+ List< OzoneAcl > inheritAcls;
+ if (createIntermediateDir) {
+ OMFileRequest.OMPathInfo pathInfo =
+ OMFileRequest.verifyFilesInPath(omMetadataManager, volumeName,
+ bucketName, keyName, Paths.get(keyName));
+ OMFileRequest.OMDirectoryResult omDirectoryResult =
+ pathInfo.getDirectoryResult();
+ inheritAcls = pathInfo.getAcls();
+
+ // Check if a file or directory exists with same key name.
+ if (omDirectoryResult == DIRECTORY_EXISTS) {
+ throw new OMException("Can not write to directory: " + keyName,
Review comment:
Let's make the exception message slightly more descriptive to explain
what is really going on. We can mention that createIntermediateDirs behavior is
enabled and hence `/` has special interpretation.
----------------------------------------------------------------
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]