From 11a7570f51c926e6cdd6c1a21b628d6a80e48e13 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Wed, 9 Aug 2017 19:11:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D1=87=D0=B8=D1=82=D1=8B=D0=B2=D0=B0?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D1=83=D1=81=D1=82=D0=BE=D0=B9=20input=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2?= =?UTF-8?q?=20FindByUsername?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/capes/files/repository.go | 4 ++++ db/skins/redis/commands.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/db/capes/files/repository.go b/db/capes/files/repository.go index 0c70e31..ce16c4d 100644 --- a/db/capes/files/repository.go +++ b/db/capes/files/repository.go @@ -14,6 +14,10 @@ type filesDb struct { func (repository *filesDb) FindByUsername(username string) (model.Cape, error) { var record model.Cape + if username == "" { + return record, CapeNotFoundError{username} + } + capePath := path.Join(repository.path, strings.ToLower(username) + ".png") file, err := os.Open(capePath) if err != nil { diff --git a/db/skins/redis/commands.go b/db/skins/redis/commands.go index 75f9ad7..4ac3298 100644 --- a/db/skins/redis/commands.go +++ b/db/skins/redis/commands.go @@ -18,6 +18,10 @@ const accountIdToUsernameKey string = "hash:username-to-account-id" func (db *redisDb) FindByUsername(username string) (model.Skin, error) { var record model.Skin + if username == "" { + return record, SkinNotFoundError{username} + } + redisKey := buildKey(username) response := db.conn.Cmd("GET", redisKey) if response.IsType(redis.Nil) {