Skip to content

Commit a1ac730

Browse files
author
Paul Johnson
committed
Added XML configuration support for cleanup policy
1 parent d865448 commit a1ac730

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ internal class ContentElement : UmbracoConfigurationElement, IContentSection
2222
[ConfigurationProperty("notifications", IsRequired = true)]
2323
internal NotificationsElement Notifications => (NotificationsElement) base["notifications"];
2424

25+
[ConfigurationProperty("contentVersionCleanupPolicy", IsRequired = false)]
26+
internal ContentVersionCleanupPolicyElement ContentVersionCleanupPolicy => (ContentVersionCleanupPolicyElement) this["contentVersionCleanupPolicy"];
27+
2528
[ConfigurationProperty("PreviewBadge")]
2629
internal InnerTextConfigurationElement<string> PreviewBadge => GetOptionalTextElement("PreviewBadge", DefaultPreviewBadge);
2730

@@ -61,6 +64,8 @@ internal class ContentElement : UmbracoConfigurationElement, IContentSection
6164

6265
IEnumerable<string> IContentSection.AllowedUploadFiles => AllowedUploadFiles;
6366

67+
IContentVersionCleanupPolicySettings IContentSection.ContentVersionCleanupPolicySettings => ContentVersionCleanupPolicy;
68+
6469
bool IContentSection.ShowDeprecatedPropertyEditors => ShowDeprecatedPropertyEditors;
6570

6671
string IContentSection.LoginBackgroundImage => LoginBackgroundImage;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Configuration;
2+
3+
namespace Umbraco.Core.Configuration.UmbracoSettings
4+
{
5+
internal class ContentVersionCleanupPolicyElement : UmbracoConfigurationElement, IContentVersionCleanupPolicySettings
6+
{
7+
[ConfigurationProperty("enable", DefaultValue = false)]
8+
public bool EnableCleanup => (bool)this["enable"];
9+
10+
[ConfigurationProperty("keepAllVersionsNewerThanDays", DefaultValue = 2)]
11+
public int KeepAllVersionsNewerThanDays => (int)this["keepAllVersionsNewerThanDays"];
12+
13+
[ConfigurationProperty("keepLatestVersionPerDayForDays", DefaultValue = 30)]
14+
public int KeepLatestVersionPerDayForDays => (int)this["keepLatestVersionPerDayForDays"];
15+
}
16+
}

src/Umbraco.Core/Configuration/UmbracoSettings/IContentSection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public interface IContentSection : IUmbracoConfigurationSection
2525

2626
IEnumerable<string> AllowedUploadFiles { get; }
2727

28+
IContentVersionCleanupPolicySettings ContentVersionCleanupPolicySettings { get; }
29+
2830
/// <summary>
2931
/// Gets a value indicating whether to show deprecated property editors in
3032
/// a datatype list of available editors.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Umbraco.Core.Configuration.UmbracoSettings
2+
{
3+
public interface IContentVersionCleanupPolicySettings
4+
{
5+
bool EnableCleanup { get; }
6+
int KeepAllVersionsNewerThanDays { get; }
7+
int KeepLatestVersionPerDayForDays { get; }
8+
}
9+
}

src/Umbraco.Core/Umbraco.Core.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
<Compile Include="AssemblyExtensions.cs" />
131131
<Compile Include="Collections\StackQueue.cs" />
132132
<Compile Include="Configuration\ICoreDebug.cs" />
133+
<Compile Include="Configuration\UmbracoSettings\ContentVersionCleanupPolicyElement.cs" />
134+
<Compile Include="Configuration\UmbracoSettings\IContentVersionCleanupPolicySettings.cs" />
133135
<Compile Include="Constants-CharArrays.cs" />
134136
<Compile Include="Collections\EventClearingObservableCollection.cs" />
135137
<Compile Include="Constants-Sql.cs" />

src/Umbraco.Web.UI/config/umbracoSettings.Release.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@
190190

191191
<!-- You can specify your own logo for the login screen here. This path is relative to the ~/umbraco path. The default location is: /umbraco/assets/img/application/umbraco_logo_white.svg -->
192192
<loginLogoImage>assets/img/application/umbraco_logo_white.svg</loginLogoImage>
193+
194+
<contentVersionCleanupPolicy enable="true" keepAllVersionsNewerThanDays="2" keepLatestVersionPerDayForDays="30" />
193195
</content>
194196

195197
<security>

0 commit comments

Comments
 (0)