fix: Add logging to Windows permissions checks #548
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As called out in #444, we need to provide a little more help in debugging some directory permission failures. This PR adds an
ILogger
to theWindowsFileSystemUtils
class, so that we can log the Exceptions that are caught in that class.There was a //TODO in the original code, suggesting that we would log this at
Debug
level. This makes total sense, but I encountered a problem when testing this--theConfig
that exposes the user-configured verbosity level only becomes available after we need to create theWindowsFileSystemUtils
, and none of the variations I tried were successful in altering that order. Due to this, I opted to log the error atWarning
level, so that it would show up with the default settings but not show up as the key problem.Testing
I inserted a test Exception inside the
DirectoryHasRights
method and tested locally to confirm that the Exception appears as a warning in the output. I then removed the test Exception and tested the following scenarios locally to ensure that our "expected" scenarios work without displaying an additional Exception:The net result is that the new warning displays only in cases where an Exception is thrown inside
WindowsFileSystemUtils.DirectoryHasRights
. Flow continues as it did before.