From 326161a5637a857622f498d916b8d463f10383df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Thu, 13 Apr 2017 02:22:18 +0200 Subject: [PATCH] Check if server exists in storage.User.SetNick() --- storage/user.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/storage/user.go b/storage/user.go index f348fdd5..0668ad56 100644 --- a/storage/user.go +++ b/storage/user.go @@ -165,11 +165,14 @@ func (u *User) SetNick(nick, address string) { id := u.serverID(address) server := Server{} - server.Unmarshal(b.Get(id)) - server.Nick = nick + v := b.Get(id) + if v != nil { + server.Unmarshal(v) + server.Nick = nick - data, _ := server.Marshal(nil) - b.Put(id, data) + data, _ := server.Marshal(nil) + b.Put(id, data) + } return nil })