smengcl commented on a change in pull request #2747:
URL: https://github.com/apache/ozone/pull/2747#discussion_r733953957



##########
File path: 
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
##########
@@ -433,7 +433,18 @@ protected void rename(final Path src, final Path dst,
       // if doesn't have TO_TRASH option, just pass the call to super
       super.rename(src, dst, options);
     } else {
-      rename(src, dst);
+      OFSPath dstpath = new OFSPath(dst);
+      String keyName = dstpath.getKeyName();
+      // omit volume name and bucket name from Key
+      String keyNamewithoutVolumeAndBucket = keyName.replace(

Review comment:
       `String.replace()` wouldn't work as expected in some edge cases.
   
   e.g.  when vol/bucket is repeated in the String: `keyName = 
/vol1/buck2/vol1/buck2/key1` becomes `/key1` after replacement with your 
current logic. But we actually expect `/vol1/buck2/key1` in this specific case 
here, right?
   
   `String.replace()` replaces ALL occurrences of the pattern. But what we 
actually want is just the **first** occurrence from the **beginning** of the 
String.
   
   I think we can just parse `keyName` into `OFSPath` and use the existing 
method `OFSPath#getKeyName`.




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