arjun4084346 commented on a change in pull request #3457:
URL: https://github.com/apache/gobblin/pull/3457#discussion_r795084628
##########
File path:
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/CopyableFile.java
##########
@@ -354,6 +359,36 @@ public static OwnerAndPermission
resolveReplicatedOwnerAndPermission(FileSystem
return ownerAndPermissions;
}
+ public static Map<String, OwnerAndPermission>
resolveReplicatedAncestorOwnerAndPermissionsRecursively(FileSystem sourceFs,
Path fromPath,
+ Path toPath, CopyConfiguration copyConfiguration) throws IOException {
+
+ Map<String, OwnerAndPermission> ownerAndPermissions = Maps.newHashMap();
+
+ // We only pass directories to this method anyways. Those directories
themselves need permissions set.
+ Path currentOriginPath = fromPath;
+ Path currentTargetPath = toPath;
+
+ if (!PathUtils.isAncestor(currentTargetPath, currentOriginPath)) {
+ throw new IOException(String.format("currentTargetPath %s must be an
ancestor of currentOriginPath %s.", currentTargetPath, currentOriginPath));
+ }
+
+ while (PathUtils.isAncestor(currentTargetPath,
currentOriginPath.getParent())) {
+
ownerAndPermissions.put(PathUtils.getPathWithoutSchemeAndAuthority(currentOriginPath).toString(),
resolveReplicatedOwnerAndPermission(sourceFs, currentOriginPath,
copyConfiguration));
+ currentOriginPath = currentOriginPath.getParent();
+ }
+ // Now currentTargetPath and currentOriginPath are the same path.
+
+ // Walk through the parents and preserve the permissions from Origin ->
Target as we go in lockstep.
+ while (currentOriginPath != null && currentTargetPath != null
Review comment:
1. For now, this logic can be used with config USE_NEW_PRESERVE_LOGIC_KEY
2. Yes, it will set permissions on /d1 and /d1/d2 as well. If user thinks
that's an issue, he should not choose this logic. At this point, there is no
friendly way to tell exactly upto which ancestors permissions need to be
applied. I have provided a config 'stopOnError' which would stop setting
permissions if it encounters any error
--
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]