AI codebase review
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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1f9429ea74
commit
5966fdd91e
@@ -0,0 +1,8 @@
|
||||
//go:build !unix
|
||||
|
||||
package platform
|
||||
|
||||
import "os"
|
||||
|
||||
// OpenContent opens a file whose content is about to be read.
|
||||
func OpenContent(path string) (*os.File, error) { return os.Open(path) }
|
||||
@@ -0,0 +1,15 @@
|
||||
//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)
|
||||
}
|
||||
Reference in New Issue
Block a user