From f9133b35493ffa94a33a57842b541a294a9db427 Mon Sep 17 00:00:00 2001 From: Meik Date: Fri, 10 Jul 2026 10:42:37 +0200 Subject: [PATCH] Improve automatic NTFS ensure diagnostics --- LiamWorkflowActivities/LiamWorkflowRuntime.cs | 59 +++++++++++++------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/LiamWorkflowActivities/LiamWorkflowRuntime.cs b/LiamWorkflowActivities/LiamWorkflowRuntime.cs index 762779e..d1c232f 100644 --- a/LiamWorkflowActivities/LiamWorkflowRuntime.cs +++ b/LiamWorkflowActivities/LiamWorkflowRuntime.cs @@ -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)) + 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); + + ResultToken ensureResult; + try { - LogEntry($"Skipping automatic NTFS permission group ensure for '{folderPath}' because the directory does not exist.", LogLevels.Warning); + ensureResult = await ntfsProvider.EnsureMissingPermissionGroupsAsync( + folderPath, + null, + null, + null, + null, + allowSharePathEnsure, + ensureTraverseInPermissionPhase, + simulateOnly); + } + catch (Exception ex) + { + LogException(ex); + LogEntry($"Automatic NTFS permission group ensure failed for '{folderPath}' with exception: {ex.Message}", LogLevels.Error); continue; } - var ensureResult = await ntfsProvider.EnsureMissingPermissionGroupsAsync( - folderPath, - null, - null, - null, - null, - allowSharePathEnsure, - !allowTraverseEnsure && (ntfsArea is cLiamNtfsFolder || ntfsArea is cLiamNtfsShare), - simulateOnly); 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( + $"Automatic NTFS traverse group ensure starting for '{folderPath}'. WhatIf={simulateOnly}", + LogLevels.Debug); + + ResultToken ensureResult; + try { - LogEntry($"Skipping automatic NTFS traverse group ensure for '{folderPath}' because the directory does not exist.", LogLevels.Warning); + 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; } - var ensureResult = await ntfsProvider.EnsureTraverseGroupsAsync( - folderPath, - null, - simulateOnly); if (ensureResult == null) { var providerMessage = ntfsProvider.GetLastErrorMessage() ?? "Provider returned no result.";