mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-02-22 14:43:01 +08:00
better error message, actually clear unused cached lookups.
This commit is contained in:
parent
49038cf51c
commit
373b4e4b83
2 changed files with 7 additions and 3 deletions
|
@ -71,7 +71,7 @@ func flattenSPFs(cfg *models.DNSConfig) []error {
|
|||
if err := cache.Save("spfcache.updated.json"); err != nil {
|
||||
errs = append(errs, err)
|
||||
} else {
|
||||
errs = append(errs, Warning{fmt.Errorf("%d spf record lookups are out of date with cache (%s). Wrote changes to dnscache.updated.json. Please rename and commit", len(changed), strings.Join(changed, ","))})
|
||||
errs = append(errs, Warning{fmt.Errorf("%d spf record lookups are out of date with cache (%s). Wrote changes to spfcache.updated.json. Please rename and commit:\nmv spfcache.updated.json spfcache.json", len(changed), strings.Join(changed, ","))})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,11 +125,15 @@ func (c *cache) ResolveErrors() (errs []error) {
|
|||
return
|
||||
}
|
||||
func (c *cache) Save(filename string) error {
|
||||
for _, entry := range c.records {
|
||||
outRecs := make(map[string]*cacheEntry, len(c.records))
|
||||
for k, entry := range c.records {
|
||||
// move resolved data into cached field
|
||||
// only take those we actually resolved
|
||||
if entry.resolvedSPF != "" {
|
||||
entry.SPF = entry.resolvedSPF
|
||||
outRecs[k] = entry
|
||||
}
|
||||
}
|
||||
dat, _ := json.MarshalIndent(c.records, "", " ")
|
||||
dat, _ := json.MarshalIndent(outRecs, "", " ")
|
||||
return ioutil.WriteFile(filename, dat, 0644)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue