duongkame commented on code in PR #3774:
URL: https://github.com/apache/ozone/pull/3774#discussion_r995034619
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -1221,28 +1223,44 @@ private OzoneFileStatus getOzoneFileStatus(OmKeyArgs
args,
// Check if the key is a file.
String fileKeyBytes = metadataManager.getOzoneKey(
volumeName, bucketName, keyName);
- fileKeyInfo = metadataManager
- .getKeyTable(getBucketLayout(metadataManager, volumeName,
bucketName))
- .get(fileKeyBytes);
+ BucketLayout layout =
+ getBucketLayout(metadataManager, volumeName, bucketName);
+ fileKeyInfo = metadataManager.getKeyTable(layout).get(fileKeyBytes);
+ String dirKey = OzoneFSUtils.addTrailingSlashIfNeeded(keyName);
// Check if the key is a directory.
if (fileKeyInfo == null) {
- String dirKey = OzoneFSUtils.addTrailingSlashIfNeeded(keyName);
String dirKeyBytes = metadataManager.getOzoneKey(
volumeName, bucketName, dirKey);
- OmKeyInfo dirKeyInfo = metadataManager.getKeyTable(
- getBucketLayout(metadataManager, volumeName, bucketName))
- .get(dirKeyBytes);
- if (dirKeyInfo != null) {
- return new OzoneFileStatus(dirKeyInfo, scmBlockSize, true);
+ dirKeyInfo = metadataManager.getKeyTable(layout).get(dirKeyBytes);
+
+ // Check if the key is a prefix.
+ // Some keys may contain '/' Ozone will treat '/' as directory
separator
+ // such as : key name is 'a/b/c', 'a' and 'b' may not really exist,
+ // but Ozone treats 'a' and 'b' as a directory.
+ // we need create a fake directory 'a' or 'a/b'
+ if (dirKeyInfo == null) {
Review Comment:
The method `getFileStatus` is getting longer. Maybe it's worth pulling this
snippet as a function.
--
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]