mirror of
				https://github.com/elyby/chrly.git
				synced 2025-05-31 14:11:51 +05:30 
			
		
		
		
	Возвращаем ошибки по ссылке в реализациях репозиториев
This commit is contained in:
		@@ -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 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user