s3/zip: extract metadata properly for Zipped objects (#15123)

s3/zip: extra metadata properly for Zipped objects

fixes #15121
This commit is contained in:
Harshavardhana
2022-06-21 14:11:12 -07:00
committed by GitHub
parent 10522438b7
commit f293df647c
2 changed files with 51 additions and 35 deletions
+21
View File
@@ -18,6 +18,7 @@
package cmd
import (
"encoding/base64"
"io"
"math"
"time"
@@ -178,6 +179,26 @@ type ObjectInfo struct {
SuccessorModTime time.Time
}
// ArchiveInfo returns any saved zip archive meta information
func (o ObjectInfo) ArchiveInfo() []byte {
if len(o.UserDefined) == 0 {
return nil
}
z, ok := o.UserDefined[archiveInfoMetadataKey]
if !ok {
return nil
}
if len(z) > 0 && z[0] >= 32 {
// FS/gateway mode does base64 encoding on roundtrip.
// zipindex has version as first byte, which is below any base64 value.
zipInfo, _ := base64.StdEncoding.DecodeString(z)
if len(zipInfo) != 0 {
return zipInfo
}
}
return []byte(z)
}
// Clone - Returns a cloned copy of current objectInfo
func (o ObjectInfo) Clone() (cinfo ObjectInfo) {
cinfo = ObjectInfo{