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