-
Notifications
You must be signed in to change notification settings - Fork 23.9k
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
windows: added Ansible.IO c# code to work on paths greater than 260 #43666
Conversation
86c3ec0
to
b98b544
Compare
# Test-Path -IsValid failed when the long path prefix is there, we don't want | ||
# to check this ourselves and just rely on Windows to validate the path when | ||
# using it | ||
if ((-not ($value.StartsWith("\\?\"))) -and (-not (Test-Path -Path $value -IsValid))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether we should not even run Expand-Environment
on the value if it starts with \\?\
to allow people to force a file/dir name with a value that's like an env var.
I've restarted the failing CI job multiple times, but it keeps coming back unstable: https://app.shippable.com/github/ansible/ansible/runs/77931/12/tests |
@mattclay thanks, looks like there's still an issue with async. Will look into it. |
a1e4d39
to
a26c0f8
Compare
a26c0f8
to
414aad2
Compare
414aad2
to
d1d90f9
Compare
cc @if-meaton |
SUMMARY
This PR adds the namespace
Ansible.IO
to theAnsible.ModuleUtils.FileUtil
that allows modules to interact with paths that exceeds MAX_PATH (~260 chars). This namespace is designed to replicate the functionality ofSystem.IO.Directory/DirectoryInfo/File/FileInfo/Path
but also to add support for the following;\\?\
prefixCompress()
andDecompress()
methods to enable the toggling of the Compress attributeFurther changes to this PR are to LinkUtil which changes;
SeBackupPrivilege
when required instead of doing it globallyFirst part to achieve #43060.
ISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.FileUtil.psm1
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.LinkUtil.psm1
win_stat
win_command
win_shell
win_wait_for
ANSIBLE VERSION
ADDITIONAL INFORMATION
There is a lot of code in the Ansible.ModuleUtils.FileUtil.psm1 is slightly modified from https://github.com/dotnet/corefx which is licensed under the MIT license. When doing some testing against devel, the
win_stat
tests only took an extra 1-3 seconds so the extra code does not seem to slow anything down dramatically.