mirror of
https://github.com/elyby/chrly.git
synced 2024-12-27 15:30:44 +05:30
Возвращаем ошибки по ссылке в реализациях репозиториев
This commit is contained in:
parent
428bedf301
commit
d9629b5e83
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user