#1: Implement UuidsStorage in Redis

This commit is contained in:
ErickSkrauch
2019-04-25 02:23:10 +03:00
parent 533afcc689
commit f3690686ec
3 changed files with 57 additions and 7 deletions

View File

@@ -5,12 +5,13 @@ import (
"path"
"strings"
"github.com/elyby/chrly/api/mojang/queue"
"github.com/elyby/chrly/interfaces"
"github.com/elyby/chrly/model"
)
type FilesystemFactory struct {
BasePath string
BasePath string
CapesDirName string
}
@@ -26,6 +27,10 @@ func (f FilesystemFactory) CreateCapesRepository() (interfaces.CapesRepository,
return &filesStorage{path: path.Join(f.BasePath, f.CapesDirName)}, nil
}
func (f FilesystemFactory) CreateMojangUuidsRepository() (queue.UuidsStorage, error) {
panic("implement me")
}
func (f FilesystemFactory) validateFactoryConfig() error {
if f.BasePath == "" {
return &ParamRequired{"basePath"}
@@ -47,7 +52,7 @@ func (repository *filesStorage) FindByUsername(username string) (*model.Cape, er
return nil, &CapeNotFoundError{username}
}
capePath := path.Join(repository.path, strings.ToLower(username) + ".png")
capePath := path.Join(repository.path, strings.ToLower(username)+".png")
file, err := os.Open(capePath)
if err != nil {
return nil, &CapeNotFoundError{username}