From d707049f724bc6f6e44ef3ae5f9899a1c8abf9b4 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Tue, 16 Oct 2018 20:50:09 -0400 Subject: [PATCH] don't make a backup of a nil state This makes sure we don't create a backup of an intermediate state if the first read state was empty. --- states/statemgr/filesystem.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/states/statemgr/filesystem.go b/states/statemgr/filesystem.go index 51cc31037..c9011162e 100644 --- a/states/statemgr/filesystem.go +++ b/states/statemgr/filesystem.go @@ -240,6 +240,12 @@ func (s *Filesystem) RefreshState() error { } f, err := statefile.Read(reader) + + // nothing to backup if there's no initial state + if f == nil { + s.writtenBackup = true + } + // if there's no state we just assign the nil return value if err != nil && err != statefile.ErrNoState { return err