diff --git a/api/handler/attributes.go b/api/handler/attributes.go index 3710675..b19b15d 100644 --- a/api/handler/attributes.go +++ b/api/handler/attributes.go @@ -216,7 +216,7 @@ func formUploadAttributes(info *data.ObjectInfo, maxParts, marker int) (*ObjectP for i, p := range partInfos { part, err := layer.ParseCompletedPartHeader(p) if err != nil { - return nil, fmt.Errorf("invalid competed part: %w", err) + return nil, fmt.Errorf("invalid completed part: %w", err) } parts[i] = Part{ PartNumber: part.PartNumber, diff --git a/api/layer/encryption/encryption.go b/api/layer/encryption/encryption.go index f035ae0..1b71b73 100644 --- a/api/layer/encryption/encryption.go +++ b/api/layer/encryption/encryption.go @@ -54,8 +54,8 @@ type Decrypter struct { decLen uint64 skipLen uint64 - ln uint64 - off uint64 + length uint64 + offset uint64 } const ( @@ -197,12 +197,12 @@ func (d Decrypter) DecryptedLength() uint64 { // EncryptedLength is size of encrypted data that should be read for successful decryption. func (d Decrypter) EncryptedLength() uint64 { - return d.ln + return d.length } // EncryptedOffset is offset of encrypted payload for successful decryption. func (d Decrypter) EncryptedOffset() uint64 { - return d.off + return d.offset } func (d *Decrypter) initRangeParams() { @@ -210,7 +210,7 @@ func (d *Decrypter) initRangeParams() { d.encPartRangeLen = d.parts[d.currentPart].encryptedSize if d.rangeParam == nil { d.decLen = d.partDataRemain - d.ln = d.encPartRangeLen + d.length = d.encPartRangeLen return } @@ -230,7 +230,7 @@ func (d *Decrypter) initRangeParams() { d.skipLen = (start - sum) % blockSize d.seqNumber = (start - sum) / blockSize encOffPart := d.seqNumber * fullBlockSize - d.off = encSum + encOffPart + d.offset = encSum + encOffPart d.encPartRangeLen = d.encPartRangeLen - encOffPart d.partDataRemain = d.partDataRemain + sum - start @@ -252,11 +252,11 @@ func (d *Decrypter) initRangeParams() { if endPartEnc < endEnc { endEnc = endPartEnc } - d.ln = endEnc - d.off + d.length = endEnc - d.offset d.decLen = end - start + 1 - if d.ln < d.encPartRangeLen { - d.encPartRangeLen = d.ln + if d.length < d.encPartRangeLen { + d.encPartRangeLen = d.length } if d.decLen < d.partDataRemain { d.partDataRemain = d.decLen diff --git a/api/layer/encryption/encryption_test.go b/api/layer/encryption/encryption_test.go index 7371870..a66a86a 100644 --- a/api/layer/encryption/encryption_test.go +++ b/api/layer/encryption/encryption_test.go @@ -106,8 +106,8 @@ func TestDecrypterInitParams(t *testing.T) { decReader.initRangeParams() require.Equal(t, tc.expSkipLen, decReader.skipLen) require.Equal(t, tc.expDecLen, decReader.decLen) - require.Equal(t, tc.expLn, decReader.ln) - require.Equal(t, tc.expOff, decReader.off) + require.Equal(t, tc.expLn, decReader.length) + require.Equal(t, tc.expOff, decReader.offset) require.Equal(t, tc.expDataRemain, decReader.partDataRemain) require.Equal(t, tc.expEncPartRange, decReader.encPartRangeLen) require.Equal(t, tc.expSeqNumber, decReader.seqNumber) diff --git a/api/layer/layer.go b/api/layer/layer.go index 683b1ba..3e1098a 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -11,14 +11,13 @@ import ( "strings" "time" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/encryption" - "github.com/nats-io/nats.go" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neofs-s3-gw/api" "github.com/nspcc-dev/neofs-s3-gw/api/cache" "github.com/nspcc-dev/neofs-s3-gw/api/data" "github.com/nspcc-dev/neofs-s3-gw/api/errors" + "github.com/nspcc-dev/neofs-s3-gw/api/layer/encryption" "github.com/nspcc-dev/neofs-s3-gw/api/resolver" "github.com/nspcc-dev/neofs-s3-gw/creds/accessbox" "github.com/nspcc-dev/neofs-sdk-go/bearer" diff --git a/api/layer/util.go b/api/layer/util.go index d5b8564..0302e0c 100644 --- a/api/layer/util.go +++ b/api/layer/util.go @@ -9,10 +9,9 @@ import ( "strings" "time" - "github.com/nspcc-dev/neofs-s3-gw/api/layer/encryption" - "github.com/nspcc-dev/neofs-s3-gw/api" "github.com/nspcc-dev/neofs-s3-gw/api/data" + "github.com/nspcc-dev/neofs-s3-gw/api/layer/encryption" "github.com/nspcc-dev/neofs-s3-gw/creds/accessbox" "github.com/nspcc-dev/neofs-sdk-go/object" )