mirror of https://github.com/minio/minio.git
fix: lifecycle XML parsing errors with Versioning (#9974)
This commit is contained in:
parent
d4af132fc4
commit
4cf80f96ad
|
@ -582,6 +582,7 @@ func (i *crawlItem) applyActions(ctx context.Context, o ObjectLayer, meta action
|
||||||
VersionID: obj.VersionID,
|
VersionID: obj.VersionID,
|
||||||
DeleteMarker: obj.DeleteMarker,
|
DeleteMarker: obj.DeleteMarker,
|
||||||
IsLatest: obj.IsLatest,
|
IsLatest: obj.IsLatest,
|
||||||
|
NumVersions: meta.numVersions,
|
||||||
})
|
})
|
||||||
if i.debug {
|
if i.debug {
|
||||||
logger.Info(color.Green("applyActions:")+" lifecycle: Secondary scan: %v", action)
|
logger.Info(color.Green("applyActions:")+" lifecycle: Secondary scan: %v", action)
|
||||||
|
|
|
@ -108,26 +108,13 @@ type Expiration struct {
|
||||||
DeleteMarker ExpireDeleteMarker `xml:"ExpiredObjectDeleteMarker,omitempty"`
|
DeleteMarker ExpireDeleteMarker `xml:"ExpiredObjectDeleteMarker,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalXML parses delete marker and validates if it is set.
|
|
||||||
func (b *ExpireDeleteMarker) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error {
|
|
||||||
if !*b {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var deleteMarker bool
|
|
||||||
err := d.DecodeElement(&deleteMarker, &startElement)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
*b = ExpireDeleteMarker(deleteMarker)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalXML encodes delete marker boolean into an XML form.
|
// MarshalXML encodes delete marker boolean into an XML form.
|
||||||
func (b *ExpireDeleteMarker) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error {
|
func (b ExpireDeleteMarker) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error {
|
||||||
if !*b {
|
if !b {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return e.EncodeElement(*b, startElement)
|
type expireDeleteMarkerWrapper ExpireDeleteMarker
|
||||||
|
return e.EncodeElement(expireDeleteMarkerWrapper(b), startElement)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate - validates the "Expiration" element
|
// Validate - validates the "Expiration" element
|
||||||
|
|
|
@ -204,9 +204,7 @@ func (lc Lifecycle) ComputeAction(obj ObjectOpts) Action {
|
||||||
if time.Now().After(expectedExpiryTime(obj.ModTime, rule.NoncurrentVersionExpiration.NoncurrentDays)) {
|
if time.Now().After(expectedExpiryTime(obj.ModTime, rule.NoncurrentVersionExpiration.NoncurrentDays)) {
|
||||||
return DeleteVersionAction
|
return DeleteVersionAction
|
||||||
}
|
}
|
||||||
return NoneAction
|
|
||||||
}
|
}
|
||||||
return NoneAction
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// All other expiration only applies to latest versions
|
// All other expiration only applies to latest versions
|
||||||
|
|
|
@ -36,12 +36,13 @@ var (
|
||||||
errNoncurrentVersionTransitionUnsupported = Errorf("Specifying <NoncurrentVersionTransition></NoncurrentVersionTransition> is not supported")
|
errNoncurrentVersionTransitionUnsupported = Errorf("Specifying <NoncurrentVersionTransition></NoncurrentVersionTransition> is not supported")
|
||||||
)
|
)
|
||||||
|
|
||||||
// MarshalXML if non-current days not set returns empty tags
|
// MarshalXML if non-current days not set to non zero value
|
||||||
func (n *NoncurrentVersionExpiration) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
func (n NoncurrentVersionExpiration) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
||||||
if n.NoncurrentDays == ExpirationDays(0) {
|
if n.IsDaysNull() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return e.EncodeElement(&n, start)
|
type noncurrentVersionExpirationWrapper NoncurrentVersionExpiration
|
||||||
|
return e.EncodeElement(noncurrentVersionExpirationWrapper(n), start)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDaysNull returns true if days field is null
|
// IsDaysNull returns true if days field is null
|
||||||
|
|
Loading…
Reference in New Issue