Fix Copy task case sensitivity issue on Unix systems#12147
Fix Copy task case sensitivity issue on Unix systems#12147JanProvaznik merged 8 commits intomainfrom
Conversation
Replace StringComparer.OrdinalIgnoreCase with FileUtilities.PathComparer in _directoriesKnownToExist cache to respect filesystem case sensitivity. On Unix systems, the Copy task was incorrectly treating case-different paths as the same due to using case-insensitive string comparison. This could cause false conflicts when copying to files with names that differ only in case from existing directories. FileUtilities.PathComparer automatically uses case-sensitive comparison on case-sensitive filesystems and case-insensitive comparison on case-insensitive filesystems. Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
|
@copilot apply this logic: Perhaps the cache could be case-sensitive to memorize only cases where we know the casing matches exactly, and let the task try and fail to actually copy the file if there is a directory name that differs only in casing? |
Use StringComparer.Ordinal instead of FileUtilities.PathComparer for _directoriesKnownToExist cache. This simpler approach uses case-sensitive comparison regardless of OS, only caching exact matches and letting filesystem operations handle actual conflicts. Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com>
Applied your suggestion in commit 57106a4. Changed to use Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
please undo your last commit @copilot |
…dinal Undoing the change from commit 57106a4 as requested by @YuliiaKovalova. This reverts the _directoriesKnownToExist dictionary back to using FileUtilities.PathComparer instead of StringComparer.Ordinal. Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com>
Reverted the change in commit cb22d27. The _directoriesKnownToExist dictionary now uses FileUtilities.PathComparer instead of StringComparer.Ordinal. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a case sensitivity issue in the Copy task on Unix systems where the task incorrectly reported conflicts when copying files with names that differ only in case from existing directories. The fix ensures proper filesystem-aware path comparison by replacing a hardcoded case-insensitive comparer with a filesystem-appropriate one.
- Replaced
StringComparer.OrdinalIgnoreCasewithFileUtilities.PathComparerin the directory cache - Added comprehensive test coverage for Unix case-sensitive scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Tasks/Copy.cs | Updated dictionary comparer to use filesystem-appropriate path comparison |
| src/Tasks.UnitTests/Copy_Tests.cs | Added test to verify case-sensitive path handling on Unix systems |
|
the test you created fails: CopyToFileWithSameCaseInsensitiveNameAsExistingDirectoryOnUnix |
I ran the test Could you provide more details about your testing environment? Are you:
The current implementation using Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot ensure all collections/strings which are semantically paths in the copy task use the correct comparer |
…py task Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Updated all path-related collections and comparisons in Copy.cs to use the correct comparer in commit 783bd3a:
All path semantics now correctly respect filesystem case-sensitivity. The |
|
MacOS tests: Error message |
Co-authored-by: JanProvaznik <25267098+JanProvaznik@users.noreply.github.com>
Fixed in commit 0311dcd. The test now checks actual filesystem case-sensitivity using |
|
I learned something new today, Apple FS is by default case insensitive but you can set it to sensitive when formatting a partition |
filesActuallyCopieddictionary to useFileUtilities.PathComparerpartitionsByDestinationdictionary to useFileUtilities.PathComparerFileUtilities.PathComparison💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.