mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 12:48:00 +00:00
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:
parent
82f0b53ba3
commit
a3d657ec61
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user