1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

better error message, actually clear unused cached lookups.

This commit is contained in:
Craig Peterson
2017-10-02 12:31:30 -04:00
parent 49038cf51c
commit 373b4e4b83
2 changed files with 7 additions and 3 deletions

View File

@@ -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)
}