1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-11-10 01:20:58 +01:00

Fix excess error message during writes

Fixes #2290

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2024-12-15 20:50:13 +01:00
parent e00b9d9a91
commit 443f461be9
No known key found for this signature in database

View File

@ -116,6 +116,11 @@ func (e *ExtraRecordsMan) updateRecords() {
return return
} }
// If there are no records, ignore the update.
if records == nil {
return
}
e.mu.Lock() e.mu.Lock()
defer e.mu.Unlock() defer e.mu.Unlock()
@ -143,6 +148,12 @@ func readExtraRecordsFromPath(path string) ([]tailcfg.DNSRecord, [32]byte, error
return nil, [32]byte{}, fmt.Errorf("reading path: %s, err: %w", path, err) return nil, [32]byte{}, fmt.Errorf("reading path: %s, err: %w", path, err)
} }
// If the read was triggered too fast, and the file is not complete, ignore the update
// if the file is empty. A consecutive update will be triggered when the file is complete.
if len(b) == 0 {
return nil, [32]byte{}, nil
}
var records []tailcfg.DNSRecord var records []tailcfg.DNSRecord
err = json.Unmarshal(b, &records) err = json.Unmarshal(b, &records)
if err != nil { if err != nil {