Add automatic NTFS traverse ensure
This commit is contained in:
@@ -1178,6 +1178,77 @@ namespace C4IT.LIAM
|
||||
return Task.FromResult(resultToken);
|
||||
}
|
||||
|
||||
public Task<ResultToken> EnsureTraverseGroupsAsync(
|
||||
string folderPath,
|
||||
IDictionary<string, string> customTags = null,
|
||||
bool whatIf = false)
|
||||
{
|
||||
var classification = ClassifyPath(folderPath);
|
||||
if (!IsSupportedPermissionManagedPathKind(
|
||||
classification,
|
||||
eNtfsPathKind.Folder,
|
||||
eNtfsPathKind.ClassicShare,
|
||||
eNtfsPathKind.DfsLink))
|
||||
{
|
||||
return Task.FromResult(new ResultToken(System.Reflection.MethodBase.GetCurrentMethod().ToString())
|
||||
{
|
||||
resultErrorId = 30008,
|
||||
resultMessage = $"NTFS traverse ensure is only supported for folder and share paths. DFS namespaces and server roots are skipped: {folderPath}"
|
||||
});
|
||||
}
|
||||
|
||||
string matchingConfigurationKey;
|
||||
string matchingRule;
|
||||
if (IsPathBlacklisted(classification, out matchingConfigurationKey, out matchingRule))
|
||||
{
|
||||
return Task.FromResult(new ResultToken(System.Reflection.MethodBase.GetCurrentMethod().ToString())
|
||||
{
|
||||
resultErrorId = 30008,
|
||||
resultMessage = $"NTFS traverse ensure skipped for '{folderPath}' due to AdditionalConfiguration rule '{matchingConfigurationKey}={matchingRule}'."
|
||||
});
|
||||
}
|
||||
|
||||
if (!IsTraversePermissionManagedPath(folderPath))
|
||||
{
|
||||
return Task.FromResult(new ResultToken(System.Reflection.MethodBase.GetCurrentMethod().ToString())
|
||||
{
|
||||
resultErrorId = 30008,
|
||||
resultMessage = $"NTFS traverse ensure skipped for '{folderPath}' because the path is not managed by the traverse configuration."
|
||||
});
|
||||
}
|
||||
|
||||
var parentPath = GetEngineParentPath(classification, folderPath);
|
||||
var engine = CreateFilesystemEngine(
|
||||
folderPath,
|
||||
parentPath,
|
||||
customTags,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
engine.WhatIf = whatIf;
|
||||
|
||||
return Task.FromResult(engine.ensureTraversePermissionsOnly());
|
||||
}
|
||||
|
||||
private static string GetEngineParentPath(cNtfsPathClassification classification, string folderPath)
|
||||
{
|
||||
if (classification != null && !string.IsNullOrWhiteSpace(classification.ParentPath))
|
||||
return classification.ParentPath;
|
||||
|
||||
if (classification != null && !string.IsNullOrWhiteSpace(classification.ParentBoundaryPath))
|
||||
return classification.ParentBoundaryPath;
|
||||
|
||||
try
|
||||
{
|
||||
var parentPath = Directory.GetParent(folderPath)?.FullName;
|
||||
return string.IsNullOrWhiteSpace(parentPath) ? folderPath : parentPath;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return folderPath;
|
||||
}
|
||||
}
|
||||
|
||||
private DataArea_FileSystem CreateFilesystemEngine(
|
||||
string folderPath,
|
||||
string parentFolderPath,
|
||||
|
||||
Reference in New Issue
Block a user