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) {
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 {