a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
//go:build linux
|
|
|
|
package indexer
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"syscall"
|
|
)
|
|
|
|
// slowWatchMount reports whether path lives on a filesystem where native
|
|
// fsnotify is unreliable or prohibitively slow — notably a Windows drive
|
|
// surfaced into WSL2 via 9p/drvfs (inotify events arrive late or never), or
|
|
// an SMB/CIFS share. On such a mount the watcher disables fsnotify and
|
|
// relies on the adaptive poller + git hooks. GORTEX_FORCE_FSNOTIFY=1 forces
|
|
// native fsnotify on regardless.
|
|
func slowWatchMount(path string) bool {
|
|
if path == "" || os.Getenv("GORTEX_FORCE_FSNOTIFY") == "1" {
|
|
return false
|
|
}
|
|
if !runningUnderWSL() {
|
|
return false
|
|
}
|
|
var st syscall.Statfs_t
|
|
if err := syscall.Statfs(path, &st); err != nil {
|
|
return false
|
|
}
|
|
switch int64(st.Type) {
|
|
case 0x01021997, // V9FS_MAGIC — 9p, WSL2's drvfs transport for Windows drives
|
|
0xFF534D42: // CIFS_MAGIC — SMB/CIFS share
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
// runningUnderWSL reports whether the process is inside the Windows
|
|
// Subsystem for Linux, probed from /proc/version's microsoft/WSL marker.
|
|
func runningUnderWSL() bool {
|
|
b, err := os.ReadFile("/proc/version")
|
|
if err != nil {
|
|
return false
|
|
}
|
|
v := strings.ToLower(string(b))
|
|
return strings.Contains(v, "microsoft") || strings.Contains(v, "wsl")
|
|
}
|