fix(check-ip): create cache dir before httpcache writes into it

httpcache.Cacher.Fetch writes to <path>.tmp without MkdirAll; the
library expects the caller to own the directory. cacheDir now
MkdirAll's before returning.
This commit is contained in:
AJ ONeal 2026-04-20 14:15:52 -06:00
parent 82f0b53ba3
commit a3d657ec61
No known key found for this signature in database

View File

@ -334,14 +334,18 @@ func loadWhitelist(paths string) (*ipcohort.Cohort, error) {
} }
func cacheDir(override string) (string, error) { func cacheDir(override string) (string, error) {
if override != "" { dir := override
return override, nil if dir == "" {
base, err := os.UserCacheDir()
if err != nil {
return "", err
}
dir = filepath.Join(base, "bitwire-it")
} }
base, err := os.UserCacheDir() if err := os.MkdirAll(dir, 0o755); err != nil {
if err != nil {
return "", err return "", err
} }
return filepath.Join(base, "bitwire-it"), nil return dir, nil
} }
func splitCSV(s string) []string { func splitCSV(s string) []string {