fix(restore): retain legacy part-size compatibility

Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
Feng Ruohang
2026-11-03 22:32:55 +08:00
parent 4f72d0ea94
commit d9837fb319
2 changed files with 62 additions and 3 deletions
+8 -2
View File
@@ -2728,8 +2728,14 @@ func (er erasureObjects) restoreTransitionedObject(ctx context.Context, bucket s
// rehydrate the parts back on disk as per the original xl.meta prior to transition
for _, partInfo := range oi.Parts {
// Stored and logical lengths differ for compressed/encrypted data.
hr, err := hash.NewReader(ctx, io.LimitReader(gr, partInfo.Size), partInfo.Size, "", "", partInfo.ActualSize)
// Old uncompressed parts may not record ActualSize. Encrypted parts
// derive it from the written ciphertext in PutObjectPart; compressed
// parts need their recorded logical length, including valid zero sizes.
actualSize := partInfo.Size
if oi.IsCompressed() {
actualSize = partInfo.ActualSize
}
hr, err := hash.NewReader(ctx, io.LimitReader(gr, partInfo.Size), partInfo.Size, "", "", actualSize)
if err != nil {
return setRestoreHeaderFn(oi, err)
}