satellite/metainfo: override StreamMeta only if needed

For backward compatibility we are overriding pb.StreamMeta
values returned as encrypted metadata. It turns out that we
should do it not when target values are missing but when
values to override exists.

This was causing problems after move operation. Details can be
found here https://github.com/storj/uplink/issues/70

Backward compatibility test will be added to storj/uplink testsuite.

Change-Id: I72e7a01226b1dd62902cb0d6ebb1ff91a4693005
This commit is contained in:
Michał Niewrzał 2021-12-06 17:41:36 +01:00 committed by Michal Niewrzal
parent a41758bba5
commit c33d2f58cf

View File

@ -2623,17 +2623,16 @@ func (endpoint *Endpoint) objectEntryToProtoListItem(ctx context.Context, bucket
return nil, err
}
// TODO is this enough to handle old uplinks
if streamMeta.EncryptionBlockSize == 0 {
if entry.Encryption != (storj.EncryptionParameters{}) {
streamMeta.EncryptionType = int32(entry.Encryption.CipherSuite)
streamMeta.EncryptionBlockSize = entry.Encryption.BlockSize
}
if streamMeta.EncryptionType == 0 {
streamMeta.EncryptionType = int32(entry.Encryption.CipherSuite)
}
if streamMeta.NumberOfSegments == 0 {
if entry.SegmentCount != 0 {
streamMeta.NumberOfSegments = int64(entry.SegmentCount)
}
if streamMeta.LastSegmentMeta == nil {
if entry.EncryptedMetadataEncryptedKey != nil {
streamMeta.LastSegmentMeta = &pb.SegmentMeta{
EncryptedKey: entry.EncryptedMetadataEncryptedKey,
KeyNonce: entry.EncryptedMetadataNonce,