fix: duplicate search no longer hangs on files swapped for FIFOs Candidates were reopened by path with os.Open after the scan. A file replaced by a FIFO (or a symlink to one) blocked open(2) forever, and context cancellation could not interrupt it, wedging the duplicate view and --duplicates. Content is now opened with O_NOFOLLOW|O_NONBLOCK on Unix; the existing regular-file check then skips it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 lines
421 B
Go
16 lines
421 B
Go
//go:build unix
|
|
|
|
package platform
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// OpenContent opens a file whose content is about to be read. It does not
|
|
// follow a final symlink, and O_NONBLOCK keeps a FIFO swapped in since the
|
|
// scan from blocking open(2) forever; callers still check the file type.
|
|
func OpenContent(path string) (*os.File, error) {
|
|
return os.OpenFile(path, os.O_RDONLY|syscall.O_NOFOLLOW|syscall.O_NONBLOCK, 0)
|
|
}
|