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.
This commit is contained in:
James Bardin 2018-10-16 20:50:09 -04:00
parent 0a0eece15c
commit d707049f72
1 changed files with 6 additions and 0 deletions

View File

@ -240,6 +240,12 @@ func (s *Filesystem) RefreshState() error {
} }
f, err := statefile.Read(reader) 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 there's no state we just assign the nil return value
if err != nil && err != statefile.ErrNoState { if err != nil && err != statefile.ErrNoState {
return err return err