arjun4084346 commented on code in PR #4020:
URL: https://github.com/apache/gobblin/pull/4020#discussion_r1712291646


##########
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/ManifestBasedDataset.java:
##########
@@ -157,20 +161,24 @@ public Iterator<FileSet<CopyEntity>> 
getFileSetIterator(FileSystem targetFs, Cop
           toDelete.add(targetFs.getFileStatus(fileToCopy));
         }
       }
-      // Only set permission for newly created folders on target
-      // To change permissions for existing dirs, expectation is to add the 
folder to the manifest
-      Set<String> parentFolders = new 
HashSet<>(flattenedAncestorPermissions.keySet());
-      for (String folder : parentFolders) {
-        if (targetFs.exists(new Path(folder))) {
-          flattenedAncestorPermissions.remove(folder);
-        }
-      }
-      // We need both precommit step to create the directories copying to, and 
a postcommit step to ensure that the execute bit needed for recursive rename is 
reset
+
+      // Precreate the directories to avoid an edge case where recursive 
rename can create extra directories in the target
       CommitStep createDirectoryWithPermissionsCommitStep = new 
CreateDirectoryWithPermissionsCommitStep(targetFs, ancestorOwnerAndPermissions, 
this.properties);
-      CommitStep setPermissionCommitStep = new 
SetPermissionCommitStep(targetFs, flattenedAncestorPermissions, 
this.properties);
       copyEntities.add(new PrePublishStep(datasetURN(), Maps.newHashMap(), 
createDirectoryWithPermissionsCommitStep, 1));
-      copyEntities.add(new PostPublishStep(datasetURN(), Maps.newHashMap(), 
setPermissionCommitStep, 1));
 
+      if (this.enableSetPermissionPostPublish) {
+        for (String parent : ancestorOwnerAndPermissions.keySet()) {
+          Path currentPath = new Path(parent);
+          for (OwnerAndPermission ownerAndPermission : 
ancestorOwnerAndPermissions.get(parent)) {
+            if 
(!flattenedAncestorPermissions.containsKey(currentPath.toString()) && 
!targetFs.exists(currentPath)) {
+              flattenedAncestorPermissions.put(currentPath.toString(), 
ownerAndPermission);

Review Comment:
   On left side, the `value` we are putting is output of 
`resolveReplicatedAncestorOwnerAndPermissionsRecursively` but on right it is 
the output of `replicateAncestorsOwnerAndPermission`. what is the rational 
behind this change?



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

Reply via email to