Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue during setting .WithLifecycleConfiguration (#656) #722

Merged
Merged
16 changes: 15 additions & 1 deletion Minio/DataModel/ILM/LifecycleRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public class LifecycleRule
public static readonly string LIFECYCLE_RULE_STATUS_ENABLED = "Enabled";
public static readonly string LIFECYCLE_RULE_STATUS_DISABLED = "Disabled";

private RuleFilter _ruleFilter;

public LifecycleRule()
{
_ruleFilter = new RuleFilter();
}

public LifecycleRule(AbortIncompleteMultipartUpload abortIncompleteMultipartUpload, string id,
Expand Down Expand Up @@ -67,7 +70,18 @@ public LifecycleRule(AbortIncompleteMultipartUpload abortIncompleteMultipartUplo
public Transition TransitionObject { get; set; }

[XmlElement("Filter", IsNullable = true)]
public RuleFilter Filter { get; set; }
public RuleFilter Filter
{
get => _ruleFilter;
set
{
// The filter must not be missing, even if it is empty.
if (value == null)
_ruleFilter = new RuleFilter();
else
_ruleFilter = value;
}
}

[XmlElement("NoncurrentVersionExpiration", IsNullable = true)]
public NoncurrentVersionExpiration NoncurrentVersionExpirationObject { get; set; }
Expand Down
12 changes: 10 additions & 2 deletions Minio/DataModel/ILM/NoncurrentVersionExpiration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System;
using System.Xml.Serialization;

/*
Expand All @@ -25,18 +26,25 @@

namespace Minio.DataModel.ILM;

[Serializable]
[XmlRoot(ElementName = "NoncurrentVersionExpiration")]
public class NoncurrentVersionExpiration
{
public NoncurrentVersionExpiration()
{
NoncurrentDays = null;
NewerNoncurrentVersions = null;
}

public NoncurrentVersionExpiration(uint nonCurrentDays)
public NoncurrentVersionExpiration(uint nonCurrentDays, uint? newerNoncurrentVersions = null)
{
NoncurrentDays = nonCurrentDays;
NewerNoncurrentVersions = newerNoncurrentVersions;
}

[XmlElement(ElementName = "NoncurrentDays", IsNullable = true)]
internal uint? NoncurrentDays { get; set; }
public uint? NoncurrentDays { get; set; }

[XmlElement(ElementName = "NewerNoncurrentVersions", IsNullable = true)]
public uint? NewerNoncurrentVersions { get; set; }
}
2 changes: 1 addition & 1 deletion Minio/DataModel/ILM/NoncurrentVersionTransition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ public NoncurrentVersionTransition(uint nonCurrentDays, string storageClass) : b
}

[XmlElement(ElementName = "StorageClass", IsNullable = true)]
internal string StorageClass { get; set; }
public string StorageClass { get; set; }
}