Sorry typo in the script above.
rmdir /S /Q dst
mkdir dst
mklink dst\test.txt ..\src\text.txt
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We have assets backed by Perforce that we need to duplicate into another folder hiearchy. To do this we use mklink /H to create hard links to the source files. Our makefile deletes this folder hierarchy every build, and relinks the files that are present. But I'm seeing that rmdir (or del) both change the read-only state of the source files when deleting the hard links. This then messes with Perforce's read-only tracking state, and it can't clobber the files as a result.
How is it that rmdir/del can't just delete the hardlink without modifying the attribute state?
This is on Win10.
Version 10.0.19045 Build 19045
Here's an easy repro. Create src/test.txt file and set it read-only. Then run this script 2x. Note that the rmdir changes the src/test.txt read-only state to false. That should not happen.
test.bat
rmdir /S /Q dst
mkdir dst
mklink test.txt ..\src.test\text.txt
Also why does mklink symlink creation fail for the same dual workingDir case that hard links only work for. This whole realtive to link also breaks any code that was using ln -s for posix. I don't have a path relative to the link, I just have the two folders of where the files are.
rem this succeeds, but has the read-only bug
rem mklink /H dst\test.txt src\test.txt
rem this succeeds, but creates an invalid link
rem mklink dst\test.txt src\test.txt
rem this works, but means a massive change to code using ln -s or mklink /H
rem mklink dst\test.txt ..\src\test.txt
Sorry typo in the script above.
rmdir /S /Q dst
mkdir dst
mklink dst\test.txt ..\src\text.txt
Also since this is rmdir/del recursively wiping out the source read-only state, that makes it hard since we'd have to preserve the read-only state of all files prior to the call, and then restore the state. Some content is checked out and not read-only. This is a pretty horrible bug that seems to have been in rmdir/del for years.
This is even worse.
So this bug exists in Explorer as well. I have a custom tool to search and delete a hardlink and restore read-only state to one of the other hardlinks. Unfortunately, this also finds any hardlinks in the recycle bin.
So this is something Microsoft has to fix. This totally breaks use of read-only state, and the way Perforce identifies changed files.