sadanand48 opened a new pull request, #3906:
URL: https://github.com/apache/ozone/pull/3906

   ## What changes were proposed in this pull request?
   When moving a file/dir to trash, the destination path is different for ofs 
and o3fs.  The change here is to make it same for both.
   ```
   
   o3fs -> /<vol>/<buck>/.Trash/<user>/Current/..<dir if any>..
   ofs -> /<vol>/<buck>/.Trash/<user>/Current/<vol>/<buck>/..<dir if any>..
   ```
   
   Omitting volume and bucket for ofs key since its redundant info as for a 
particular ozone key already volume and bucket is known.
   
   Most of the code for moveToTrash is duplicated from the  [hadoop client 
code](https://github.com/apache/hadoop/blob/616cea2e8068e990d24057d2b0d6090f35e21371/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/TrashPolicyDefault.java#L123
 ) and only the below if condition is a modification to the method.  
   If this part is not duplicated and the path is trimmed of volume and bucket 
name and passed to `super.moveToTrash(path)` it will fail as part of 
getFileStatus call as it would call `getFileStatus(ofs://serviceId/key)`. 
   
   ```java
    if (fs.getUri().getScheme().equals(OzoneConsts.OZONE_OFS_URI_SCHEME)) {
           OFSPath ofsPath = new OFSPath(path);
           // trimming volume and bucket in order to be compatible with o3fs
           // Also including volume and bucket name in the path is redundant as
           // the key is already in a particular volume and bucket.
           Path trimmedVolumeAndBucket =
               new Path(OzoneConsts.OZONE_URI_DELIMITER
                   + ofsPath.getKeyName());
           trashPath = makeTrashRelativePath(trashCurrent, 
trimmedVolumeAndBucket);
           baseTrashPath = makeTrashRelativePath(trashCurrent,
               trimmedVolumeAndBucket.getParent());
         } else {
           trashPath = makeTrashRelativePath(trashCurrent, path);
           baseTrashPath = makeTrashRelativePath(trashCurrent, 
path.getParent());
         }
   ```
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-5866
   
   ## How was this patch tested?
   unit test
   


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