in AdlsDotNetSDK/FileProperties/PropertyTreeNode.cs [114:161]
private bool CompareAclAndUpdateChildAclProcessed(PropertyTreeNode childNode)
{
if (CheckAllAclChildNodesProcessed())
{
// This should never be entered
throw new Exception($"Acl property of Parent: {FullPath} is getting updated more than it should be {ChildDirectoryNodes.Count + ChildFileNodes.Count}");
}
bool isAclSame = true;
// Parent should always be directory
if(Type != DirectoryEntryType.DIRECTORY)
{
throw new InvalidOperationException("The parent can never be a file");
}
HashSet<string> hset = new HashSet<string>();
foreach (var aclsEntry in Acls.Entries)
{
// If the child is a file then compare only the ACCESS acls for verifying whether acls are same
// If child is a directory even the default acls need to match also
if (!(childNode.Type == DirectoryEntryType.FILE && aclsEntry.Scope == AclScope.Default))
{
hset.Add(aclsEntry.ToString());
}
}
// At this point if the child is a file then hset only contains Access acls of the parent, if child is a directory,
// hset contains all Acls (including default) of the parent
// If the count of parent acl matches with count of child acls then only compare the individual acls
if (hset.Count == childNode.Acls.Entries.Count)
{
foreach (var aclsEntry in childNode.Acls.Entries)
{
if (!hset.Contains(aclsEntry.ToString()))
{
isAclSame = false;
break;
}
}
}
else
{
isAclSame = false;
}
AllChildSameAcl = isAclSame && AllChildSameAcl && childNode.AllChildSameAcl;
// Updates the number of childs whose acl has been compared
_numChildsAclProcessed++;
return CheckAllAclChildNodesProcessed();
}