arjun4084346 commented on a change in pull request #3457:
URL: https://github.com/apache/gobblin/pull/3457#discussion_r794414919
##########
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:
Sometimes user just wants to.
e.g. if source dir structure is /d1/d2/dataset/partition/hourly/2022/01/25/10
and they want to copy /d1/d2/dataset/partition/hourly/2022/01/25 and still
wants to replicate permissions on /d1/d2/dataset/partition,
/d1/d2/dataset/partition/hourly, /d1/d2/dataset/partition/hourly,
/d1/d2/dataset/partition/hourly/2022, /d1/d2/dataset/partition/hourly/2022/01
then this option will be needed
--
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]