Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnBeforeTraverse and OnAfterTraverse to Invoke-TraverseDirectory #190

Closed
plastikfan opened this issue Apr 11, 2022 · 1 comment
Closed
Assignees
Labels
feature New feature or request

Comments

@plastikfan
Copy link
Collaborator

This allows the client to provide a callback to be invoked just before (OnBeforeTraverse) a directory has been traversed and then afterwards (OnAfterTraverse ). But we only invoke these, is the directory being traverse contains sub-directories; ie it is not a leaf directory (any place that invokes Get-ChildItem, should be wrapped with OnBefore/OnAfer).

eg, currently:

      # Now perform start of recursive traversal
      #
      [System.IO.DirectoryInfo[]]$directoryInfos = Get-ChildItem -Path $Path `
        -Directory | Where-Object { $Condition.InvokeReturnAsIs($_) }

      if ($directoryInfos) {
        $directoryInfos | Invoke-ForeachFsItem -Directory -Block $adapter `
          -Exchange $Exchange -Condition $Condition -Summary $Summary;
      }

would become:

      # Now perform start of recursive traversal
      #
      [System.IO.DirectoryInfo[]]$directoryInfos = Get-ChildItem -Path $Path `
        -Directory | Where-Object { $Condition.InvokeReturnAsIs($_) }

      if ($directoryInfos.Count -gt 0) {
        # Invoke-OnBeforeTraverse
      }
      if ($directoryInfos) {
        $directoryInfos | Invoke-ForeachFsItem -Directory -Block $adapter `
          -Exchange $Exchange -Condition $Condition -Summary $Summary;
      }

      if ($directoryInfos.Count -gt 0) {
        # Invoke-OnAfterTraverse
      }
@plastikfan plastikfan added the feature New feature or request label Apr 11, 2022
@plastikfan plastikfan self-assigned this Apr 11, 2022
@plastikfan
Copy link
Collaborator Author

This would allow a client to perform once per traversal level functionality, eg check the existence of a custom options file, or whatever else is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant