From 3479d5a93ee6007c11f5fabdc8723566934ab06c Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 8 Nov 2024 12:06:54 +0800 Subject: [PATCH] node: require LocalAppData variable (#19132) --- node/defaults.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/node/defaults.go b/node/defaults.go index f43fbeec98bd3..8baa8b6e39356 100644 --- a/node/defaults.go +++ b/node/defaults.go @@ -78,13 +78,14 @@ func DefaultDataDir() string { } func windowsAppData() string { - if v := os.Getenv("LOCALAPPDATA"); v != "" { - return v // Vista+ + v := os.Getenv("LOCALAPPDATA") + 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 filepath.Join(v, "Local") - } - return "" + return v } func isNonEmptyDir(dir string) bool {