dombizita commented on code in PR #4478:
URL: https://github.com/apache/ozone/pull/4478#discussion_r1157122410


##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java:
##########
@@ -430,8 +430,14 @@ private boolean renameFSO(OzoneBucket bucket,
     // construct src and dst key paths
     String srcKeyPath = srcPath.getNonKeyPathNoPrefixDelim() +
         OZONE_URI_DELIMITER + srcPath.getKeyName();
-    String dstKeyPath = dstPath.getNonKeyPathNoPrefixDelim() +
-        OZONE_URI_DELIMITER + dstPath.getKeyName();
+    String dstKeyPath;
+    if (dstPath.isBucket()) {
+      dstKeyPath = dstPath.getNonKeyPathNoPrefixDelim() +
+          OZONE_URI_DELIMITER + srcPath.getFileName();
+    } else {
+      dstKeyPath = dstPath.getNonKeyPathNoPrefixDelim() +
+          OZONE_URI_DELIMITER + dstPath.getKeyName();

Review Comment:
   with this logic also the non FSO destinations can have an empty key name, as 
the path can also be `vol/buck/dir1/dir2/key` and the destination can be 
`/vol/buck` too. that is why there is this part in `BasicRootedOzoneFileSystem` 
in the `rename()` method, to avoid that case and that is why it is not failing 
in a case like that in the `OMKeyRenameRequest`.
   ```
   else if (dstStatus.isDirectory()) {
     // If dst is a directory, rename source as subpath of it.
     // for example rename /source to /dst will lead to /dst/source
     dst = new Path(dst, src.getName());
     FileStatus[] statuses;
     try {
       statuses = listStatus(dst);
     } catch (FileNotFoundException fnde) {
       statuses = null;
     }
   
     if (statuses != null && statuses.length > 0) {
       // If dst exists and not a directory not empty
       LOG.warn("Failed to rename {} to {}, file already exists" +
           " or not empty!", src, dst);
       return false;
     }
    ```



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