Учитываем пустой input для методов FindByUsername

This commit is contained in:
ErickSkrauch 2017-08-09 19:11:53 +03:00
parent 676ba03c37
commit 11a7570f51
2 changed files with 8 additions and 0 deletions

View File

@ -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 {

View File

@ -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) {