Do not follow Reparse Points during copy #305
Closed
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.
Problem
Winfile follows Reparse Points during copy and tries to copy files more than once, which results in error message, that the files already exist
How to test
Download ln.exe from https://schinagl.priv.at/nt/ln/ln64.zip and place it in the same directory as the below .bat file.
Start TestCopyReparsePoint.bat from an administrative command prompt (or grant yourself the right to create symbolic links) in your e.g. temp directory.
It builds a structure like
Navigate to x:\sl in Winfile and copy it e.g. via Drag and CTRL to x:\1. You will receive no errors opposite to the original version, which tries to copy all files below x:\sl\iLib_symlink onto itself when it has copied x:\q\sl\iLib_Symlink to its destination.
Comments to the code
Basically there is one change and it builds up on the 'skip' feature in GetNetxPair() which was introduced with #303.
In general Winfile implements the simplest of all Reparse Point copy strategies, which I called the 'Splice' method. See also the explanation of Splice in the LinkShellExtension Docu.
Winfile does the 'Splice' pattern also for inner and outer reparse points. So this will only work for absolute symbolic links. Relaive symbolic links will be copied but point to 'something'. This can not be solved for Winfile, because it needs more sophisticated symlink resolving.