From d9629b5e83bdd5d02973adcb7bb0133d86724926 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 10 Aug 2017 03:00:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=89?= =?UTF-8?q?=D0=B0=D0=B5=D0=BC=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B5=20=D0=B2=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F?= =?UTF-8?q?=D1=85=20=D1=80=D0=B5=D0=BF=D0=BE=D0=B7=D0=B8=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=B5=D0=B2?= 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 | 12 +++++------- ui/textures.go | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/db/capes/files/repository.go b/db/capes/files/repository.go index ce16c4d..9bbb3a9 100644 --- a/db/capes/files/repository.go +++ b/db/capes/files/repository.go @@ -15,13 +15,13 @@ type filesDb struct { func (repository *filesDb) FindByUsername(username string) (model.Cape, error) { var record model.Cape if username == "" { - return record, CapeNotFoundError{username} + return record, &CapeNotFoundError{username} } capePath := path.Join(repository.path, strings.ToLower(username) + ".png") file, err := os.Open(capePath) if err != nil { - return record, CapeNotFoundError{username} + return record, &CapeNotFoundError{username} } record.File = file diff --git a/db/skins/redis/commands.go b/db/skins/redis/commands.go index 4ac3298..188b29a 100644 --- a/db/skins/redis/commands.go +++ b/db/skins/redis/commands.go @@ -19,13 +19,13 @@ 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} + return record, &SkinNotFoundError{username} } redisKey := buildKey(username) response := db.conn.Cmd("GET", redisKey) if response.IsType(redis.Nil) { - return record, SkinNotFoundError{username} + return record, &SkinNotFoundError{username} } encodedResult, err := response.Bytes() @@ -33,21 +33,19 @@ func (db *redisDb) FindByUsername(username string) (model.Skin, error) { result, err := zlibDecode(encodedResult) if err != nil { log.Println("Cannot uncompress zlib for key " + redisKey) - goto finish + return record, err } err = json.Unmarshal(result, &record) if err != nil { log.Println("Cannot decode record data for key" + redisKey) - goto finish + return record, nil } record.OldUsername = record.Username } - finish: - - return record, err + return record, nil } func (db *redisDb) FindByUserId(id int) (model.Skin, error) { diff --git a/ui/textures.go b/ui/textures.go index d5d089c..1afb8b5 100644 --- a/ui/textures.go +++ b/ui/textures.go @@ -61,6 +61,7 @@ func (s *uiService) Textures(response http.ResponseWriter, request *http.Request cape, err := s.capesRepo.FindByUsername(username) if err == nil { + // TODO: восстановить функционал получения ссылки на плащ // capeUrl, err := services.Router.Get("cloaks").URL("username", username) capeUrl := "/capes/" + username if err != nil {