ipn: don't log if legacy prefs don't exist (the normal case these days)

This commit is contained in:
Brad Fitzpatrick 2020-09-17 07:59:55 -07:00
parent 815bf017fc
commit c41947903a
2 changed files with 6 additions and 3 deletions

View File

@ -8,6 +8,7 @@
"context"
"errors"
"fmt"
"os"
"strings"
"sync"
"time"
@ -669,7 +670,9 @@ func (b *LocalBackend) loadStateLocked(key StateKey, prefs *Prefs, legacyPath st
if legacyPath != "" {
b.prefs, err = LoadPrefs(legacyPath)
if err != nil {
b.logf("Failed to load legacy prefs: %v", err)
if !os.IsNotExist(err) {
b.logf("Failed to load legacy prefs: %v", err)
}
b.prefs = NewPrefs()
} else {
b.logf("Imported state from relaynode for %q", key)

View File

@ -228,11 +228,11 @@ func (p *Prefs) Clone() *Prefs {
func LoadPrefs(filename string) (*Prefs, error) {
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("loading prefs from %q: %v", filename, err)
return nil, fmt.Errorf("LoadPrefs open: %w", err) // err includes path
}
p, err := PrefsFromBytes(data, false)
if err != nil {
return nil, fmt.Errorf("decoding prefs in %q: %v", filename, err)
return nil, fmt.Errorf("LoadPrefs(%q) decode: %w", filename, err)
}
return p, nil
}