satellite/metainfo: align object version format with minio
For some reason minio sometimes validates versionID as UUID. Until we decide what to do lets align our version format with it. Change-Id: I6e9832d0adc1d3b6e3f46688b386e0e118219038
This commit is contained in:
parent
f2ccb910df
commit
e592138c51
@ -371,14 +371,14 @@ const MaxVersion = Version(math.MaxInt32)
|
||||
// TODO(ver): this is not final approach to version encoding. It's simplified
|
||||
// version for internal testing purposes. Will be changed in future.
|
||||
func (v Version) Encode() []byte {
|
||||
var bytes [8]byte
|
||||
var bytes [16]byte
|
||||
binary.BigEndian.PutUint64(bytes[:], uint64(v))
|
||||
return bytes[:]
|
||||
}
|
||||
|
||||
// VersionFromBytes decodes version from bytes.
|
||||
func VersionFromBytes(bytes []byte) (Version, error) {
|
||||
if len(bytes) != 8 {
|
||||
if len(bytes) != 16 {
|
||||
return Version(0), ErrInvalidRequest.New("invalid version")
|
||||
}
|
||||
return Version(binary.BigEndian.Uint64(bytes)), nil
|
||||
|
@ -83,6 +83,18 @@ func TestEndpoint_Object_No_StorageNodes(t *testing.T) {
|
||||
t.Run("get objects", func(t *testing.T) {
|
||||
defer ctx.Check(deleteBucket)
|
||||
|
||||
// check version validation
|
||||
_, err := satellite.Metainfo.Endpoint.GetObject(ctx, &pb.GetObjectRequest{
|
||||
Header: &pb.RequestHeader{
|
||||
ApiKey: apiKey.SerializeRaw(),
|
||||
},
|
||||
Bucket: []byte("test-bucket"),
|
||||
EncryptedObjectKey: []byte("test-object"),
|
||||
ObjectVersion: []byte("broken-version"),
|
||||
})
|
||||
require.Error(t, err)
|
||||
require.True(t, errs2.IsRPC(err, rpcstatus.InvalidArgument))
|
||||
|
||||
files := make([]string, 10)
|
||||
data := testrand.Bytes(1 * memory.KiB)
|
||||
for i := 0; i < len(files); i++ {
|
||||
|
@ -304,8 +304,8 @@ func validateBucketLabel(label []byte) error {
|
||||
}
|
||||
|
||||
func validateObjectVersion(version []byte) error {
|
||||
if len(version) != 0 && len(version) != 8 {
|
||||
return Error.New("invalid object version")
|
||||
if len(version) != 0 && len(version) != 16 {
|
||||
return Error.New("invalid object version length")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user