Improve automatic NTFS ensure diagnostics

This commit is contained in:
Meik
2026-07-10 10:42:37 +02:00
parent 10c487572d
commit f9133b3549

View File

@@ -425,6 +425,10 @@ namespace LiamWorkflowActivities
if (!allowFolderEnsure && !allowSharePathEnsure && !allowTraverseEnsure)
return true;
LogEntry(
$"Automatic NTFS ensure configured. PermissionGroups={allowFolderEnsure}, PermissionGroupsForShares={allowSharePathEnsure}, TraverseGroups={allowTraverseEnsure}, DataAreas={dataAreas.Count}, WhatIf={simulateOnly}",
LogLevels.Debug);
if (allowFolderEnsure || allowSharePathEnsure)
{
foreach (var ntfsArea in dataAreas
@@ -437,21 +441,31 @@ namespace LiamWorkflowActivities
if (string.IsNullOrWhiteSpace(folderPath))
continue;
if (!Directory.Exists(folderPath))
{
LogEntry($"Skipping automatic NTFS permission group ensure for '{folderPath}' because the directory does not exist.", LogLevels.Warning);
continue;
}
var ensureTraverseInPermissionPhase = !allowTraverseEnsure && (ntfsArea is cLiamNtfsFolder || ntfsArea is cLiamNtfsShare);
LogEntry(
$"Automatic NTFS permission group ensure starting for '{folderPath}'. AllowSharePathEnsure={allowSharePathEnsure}, EnsureTraverseInPermissionPhase={ensureTraverseInPermissionPhase}, WhatIf={simulateOnly}",
LogLevels.Debug);
var ensureResult = await ntfsProvider.EnsureMissingPermissionGroupsAsync(
ResultToken ensureResult;
try
{
ensureResult = await ntfsProvider.EnsureMissingPermissionGroupsAsync(
folderPath,
null,
null,
null,
null,
allowSharePathEnsure,
!allowTraverseEnsure && (ntfsArea is cLiamNtfsFolder || ntfsArea is cLiamNtfsShare),
ensureTraverseInPermissionPhase,
simulateOnly);
}
catch (Exception ex)
{
LogException(ex);
LogEntry($"Automatic NTFS permission group ensure failed for '{folderPath}' with exception: {ex.Message}", LogLevels.Error);
continue;
}
if (ensureResult == null)
{
var providerMessage = ntfsProvider.GetLastErrorMessage() ?? "Provider returned no result.";
@@ -477,7 +491,9 @@ namespace LiamWorkflowActivities
}
LogAutomaticNtfsEnsureDebug(folderPath, ensureResult, "permission group ensure");
LogEntry($"Automatic NTFS permission group resolve starting for '{folderPath}'.", LogLevels.Debug);
await ntfsArea.ResolvePermissionGroupsAsync(folderPath);
LogEntry($"Automatic NTFS permission group resolve finished for '{folderPath}'.", LogLevels.Debug);
}
}
@@ -491,16 +507,25 @@ namespace LiamWorkflowActivities
if (string.IsNullOrWhiteSpace(folderPath))
continue;
if (!Directory.Exists(folderPath))
{
LogEntry($"Skipping automatic NTFS traverse group ensure for '{folderPath}' because the directory does not exist.", LogLevels.Warning);
continue;
}
LogEntry(
$"Automatic NTFS traverse group ensure starting for '{folderPath}'. WhatIf={simulateOnly}",
LogLevels.Debug);
var ensureResult = await ntfsProvider.EnsureTraverseGroupsAsync(
ResultToken ensureResult;
try
{
ensureResult = await ntfsProvider.EnsureTraverseGroupsAsync(
folderPath,
null,
simulateOnly);
}
catch (Exception ex)
{
LogException(ex);
LogEntry($"Automatic NTFS traverse group ensure failed for '{folderPath}' with exception: {ex.Message}", LogLevels.Error);
continue;
}
if (ensureResult == null)
{
var providerMessage = ntfsProvider.GetLastErrorMessage() ?? "Provider returned no result.";