node: require LocalAppData variable (#19132)

This commit is contained in:
Daniel Liu 2024-11-08 17:24:31 +08:00
parent 3ed9ce95c1
commit 68d9dcbee4

View file

@ -78,13 +78,14 @@ func DefaultDataDir() string {
} }
func windowsAppData() string { func windowsAppData() string {
if v := os.Getenv("LOCALAPPDATA"); v != "" { v := os.Getenv("LOCALAPPDATA")
return v // Vista+ if v == "" {
// Windows XP and below don't have LocalAppData. Crash here because
// we don't support Windows XP and undefining the variable will cause
// other issues.
panic("environment variable LocalAppData is undefined")
} }
if v := os.Getenv("APPDATA"); v != "" { return v
return filepath.Join(v, "Local")
}
return ""
} }
func isNonEmptyDir(dir string) bool { func isNonEmptyDir(dir string) bool {