mirror of
				https://github.com/elyby/chrly.git
				synced 2025-05-31 14:11:51 +05:30 
			
		
		
		
	Resolves #28. We didn't manage to catch this error during testing, so we're normalizing its handling and hope that this will not happen again
This commit is contained in:
		@@ -4,12 +4,12 @@ import (
 | 
				
			|||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
	"compress/zlib"
 | 
						"compress/zlib"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/getsentry/raven-go"
 | 
					 | 
				
			||||||
	"github.com/mediocregopher/radix.v2/pool"
 | 
						"github.com/mediocregopher/radix.v2/pool"
 | 
				
			||||||
	"github.com/mediocregopher/radix.v2/redis"
 | 
						"github.com/mediocregopher/radix.v2/redis"
 | 
				
			||||||
	"github.com/mediocregopher/radix.v2/util"
 | 
						"github.com/mediocregopher/radix.v2/util"
 | 
				
			||||||
@@ -205,17 +205,10 @@ func findMojangUuidByUsername(username string, conn util.Cmder) (string, bool, e
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	data, _ := response.Str()
 | 
						data, _ := response.Str()
 | 
				
			||||||
	parts := strings.Split(data, ":")
 | 
						parts := strings.Split(data, ":")
 | 
				
			||||||
	// Temporary debug statement to investigate https://github.com/elyby/chrly/issues/28
 | 
						// https://github.com/elyby/chrly/issues/28
 | 
				
			||||||
	if len(parts) < 2 {
 | 
						if len(parts) < 2 {
 | 
				
			||||||
		raven.Capture(raven.NewPacketWithExtra(
 | 
							conn.Cmd("HDEL", mojangUsernameToUuidKey, key)
 | 
				
			||||||
			"mojangUsernameToUuid hash contains corrupted data",
 | 
							return "", false, fmt.Errorf("Got unexpected response from the mojangUsernameToUuid hash: \"%s\"", data)
 | 
				
			||||||
			raven.Extra{
 | 
					 | 
				
			||||||
				"rawValue": "hello world",
 | 
					 | 
				
			||||||
				"username": "this is username",
 | 
					 | 
				
			||||||
			},
 | 
					 | 
				
			||||||
		), map[string]string{})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return "", false, nil
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	timestamp, _ := strconv.ParseInt(parts[1], 10, 64)
 | 
						timestamp, _ := strconv.ParseInt(parts[1], 10, 64)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -357,6 +357,22 @@ func (suite *redisTestSuite) TestGetUuid() {
 | 
				
			|||||||
		resp := suite.cmd("HGET", "hash:mojang-username-to-uuid", "mock")
 | 
							resp := suite.cmd("HGET", "hash:mojang-username-to-uuid", "mock")
 | 
				
			||||||
		suite.Require().True(resp.IsType(redis.Nil), "should cleanup expired records")
 | 
							suite.Require().True(resp.IsType(redis.Nil), "should cleanup expired records")
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						suite.RunSubTest("exists, but corrupted record", func() {
 | 
				
			||||||
 | 
							suite.cmd("HSET",
 | 
				
			||||||
 | 
								"hash:mojang-username-to-uuid",
 | 
				
			||||||
 | 
								"mock",
 | 
				
			||||||
 | 
								"corrupted value",
 | 
				
			||||||
 | 
							)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							uuid, found, err := suite.Redis.GetUuid("Mock")
 | 
				
			||||||
 | 
							suite.Require().Empty(uuid)
 | 
				
			||||||
 | 
							suite.Require().False(found)
 | 
				
			||||||
 | 
							suite.Require().Error(err, "Got unexpected response from the mojangUsernameToUuid hash: \"corrupted value\"")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							resp := suite.cmd("HGET", "hash:mojang-username-to-uuid", "mock")
 | 
				
			||||||
 | 
							suite.Require().True(resp.IsType(redis.Nil), "should cleanup expired records")
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (suite *redisTestSuite) TestStoreUuid() {
 | 
					func (suite *redisTestSuite) TestStoreUuid() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user