Description
With the addition of the FILE_ATTRIBUTE_REPARSE_POINT skip check in commit 203bb6b all symlinks are skipped in windows during recursion.
Lines 9146 to 9147 in 7ddb6d9
I don't believe this behavior is documented, I did a build with this check disabled and it worked as expected in my limited tests of NTFS File Symlinks, Directory Symlinks, and Junctions (rarely used type of link that's processed on the FS host instead of the client, esp. to support links that are transparent to remote clients).
I also tried with 4.3.3 and it followed symlinks as expected. I actually noticed this change/regression back when I updated after the 4.3.5 release but assumed it was something unique to my setup.
For normal searches I could see maybe needing to inspect reparse point tag types if doing weird raw I/O or moving files out of a file system but I don't think there are any considerations that apply to ugrep.
- https://learn.microsoft.com/en-us/windows/win32/fileio/symbolic-link-effects-on-file-systems-functions
- https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-points-and-file-operations
I think that given symlinks have been disabled on windows that there could be untested impacts to index creation or freshness checks, would need to re-read the non-windows code to see if there's special handling not included in the OS_WIN #ifdef sections.
Otherwise it would be very nice to have symlinks working again.
Test Env Creation Script
$testRoot = New-Item -ItemType Directory -Name "test-root"
$testFile = New-Item -ItemType File -Name "hello.txt" -Path $testRoot
Set-Content -Path $testFile -Value "hello world!"
$rawDir = New-Item -ItemType Directory -Name "subdir-raw" -Path $testRoot
$symDir = New-Item -ItemType SymbolicLink -Name "subdir-symlink" -Path $testRoot -Target $rawDir
$juncDir = New-Item -ItemType Junction -Name "subdir-junction" -Path $testRoot -Target $rawDir
$testFile | Copy-Item -Destination $rawDir
New-Item -ItemType SymbolicLink -Name "hello-symlink.txt" -Path $testRoot -Target $testFile
Compress-Archive -Path $testFile -DestinationPath (Join-Path $testRoot "hello.txt.zip")
Copy-Item -Path (Join-Path $testRoot "hello.txt.zip") -Destination $rawDir
Resulting Structure
+-- hello.txt
+-- hello.txt.zip
+-- hello-symlink.txt (SymbolicLink => hello.txt)
+-- subdir-raw [Folder] (Directory)
+-- hello.txt
+-- hello.txt.zip
+-- subdir-junction [Folder] (Junction => subdir-raw)
+-- hello.txt
+-- hello.txt.zip
+-- subdir-symlink [Folder] (SymbolicLink => subdir-raw)
+-- hello.txt
+-- hello.txt.zip
"Test" Results
➜ .\ugrep-4.3.3.exe -zR 'hello' .\test-root
.\test-root\hello.txt:hello world!
.\test-root\hello-symlink.txt:hello world!
.\test-root\subdir-junction\hello.txt.zip{hello.txt}:hello world!
.\test-root\subdir-junction\hello.txt:hello world!
.\test-root\subdir-raw\hello.txt:hello world!
.\test-root\subdir-symlink\hello.txt:hello world!
.\test-root\subdir-raw\hello.txt.zip{hello.txt}:hello world!
.\test-root\subdir-symlink\hello.txt.zip{hello.txt}:hello world!
.\test-root\hello.txt.zip{hello.txt}:hello world!
➜ .\ugrep-7.4.3-patched.exe -zR 'hello' .\test-root
NOT SKIPPING REPARSE POINT: [.\test-root\hello-symlink.txt] with attr [1056] #Log stub replacing "return Type::SKIP;"
NOT SKIPPING REPARSE POINT: [.\test-root\subdir-junction] with attr [1040] #Log stub replacing "return Type::SKIP;"
NOT SKIPPING REPARSE POINT: [.\test-root\subdir-symlink] with attr [1040] #Log stub replacing "return Type::SKIP;"
.\test-root\hello-symlink.txt:hello world!
.\test-root\hello.txt:hello world!
.\test-root\subdir-raw\hello.txt:hello world!
.\test-root\subdir-symlink\hello.txt:hello world!
.\test-root\subdir-symlink\hello.txt.zip{hello.txt}:hello world!
.\test-root\subdir-raw\hello.txt.zip{hello.txt}:hello world!
.\test-root\subdir-junction\hello.txt.zip{hello.txt}:hello world!
.\test-root\subdir-junction\hello.txt:hello world!
.\test-root\hello.txt.zip{hello.txt}:hello world!
➜ .\ugrep-7.4.3.exe -zR 'hello' .\test-root
.\test-root\hello.txt:hello world!
.\test-root\subdir-raw\hello.txt:hello world!
.\test-root\hello.txt.zip{hello.txt}:hello world!
.\test-root\subdir-raw\hello.txt.zip{hello.txt}:hello world!