From a3d657ec6150544c9876d0648ce5e9670dcff9a4 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 20 Apr 2026 14:15:52 -0600 Subject: [PATCH] fix(check-ip): create cache dir before httpcache writes into it httpcache.Cacher.Fetch writes to .tmp without MkdirAll; the library expects the caller to own the directory. cacheDir now MkdirAll's before returning. --- cmd/check-ip/main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/check-ip/main.go b/cmd/check-ip/main.go index 5cece22..76a295e 100644 --- a/cmd/check-ip/main.go +++ b/cmd/check-ip/main.go @@ -334,14 +334,18 @@ func loadWhitelist(paths string) (*ipcohort.Cohort, error) { } func cacheDir(override string) (string, error) { - if override != "" { - return override, nil + dir := override + if dir == "" { + base, err := os.UserCacheDir() + if err != nil { + return "", err + } + dir = filepath.Join(base, "bitwire-it") } - base, err := os.UserCacheDir() - if err != nil { + if err := os.MkdirAll(dir, 0o755); err != nil { return "", err } - return filepath.Join(base, "bitwire-it"), nil + return dir, nil } func splitCSV(s string) []string {