From 57b3f1726537699f19599e186466d65dbd42f652 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 13 Jul 2021 14:03:05 -0700 Subject: [PATCH] ipn/ipnlocal: save prefs to disk on UpdatePrefs Regression from 6d10655dc3887f1a161015514a8555c175802b4d, which added UpdatePrefs but didn't write it out to disk. I'd planned on adding tests to state_test.go which is why I'd earlier added 46896a93118d0eecbacb4255da2df0349da9b409 to prepare for making such persistence tests easier to write, but turns out state_test.go didn't even test UpdatePrefs, so I'm staying out of there. Instead, this is tested using integration tests. Fixes #2321 Signed-off-by: Brad Fitzpatrick (cherry picked from commit 01e159b6107afa62ee96591ac90149e0ca6d1d77) --- ipn/ipnlocal/local.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 10f0fa3cb..84bdd4136 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -757,6 +757,12 @@ func (b *LocalBackend) Start(opts ipn.Options) error { newPrefs := opts.UpdatePrefs newPrefs.Persist = b.prefs.Persist b.prefs = newPrefs + + if opts.StateKey != "" { + if err := b.store.WriteState(opts.StateKey, b.prefs.ToBytes()); err != nil { + b.logf("failed to save UpdatePrefs state: %v", err) + } + } } wantRunning := b.prefs.WantRunning