From ab06d21639ae5da3c157f257e8a254d2c34f7c46 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 2 Nov 2021 10:42:51 +0100 Subject: [PATCH 1/2] Fix namespace syntax --- .../Models/ContentEditing/HistoryCleanup.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs b/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs index 7ac2fd94f2b4..23993e4395c9 100644 --- a/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs +++ b/src/Umbraco.Core/Models/ContentEditing/HistoryCleanup.cs @@ -1,16 +1,18 @@ using System.Runtime.Serialization; -namespace Umbraco.Core.Models.ContentEditing; - -[DataContract(Name = "historyCleanup", Namespace = "")] -public class HistoryCleanup +namespace Umbraco.Core.Models.ContentEditing { - [DataMember(Name = "preventCleanup")] - public bool PreventCleanup { get; set; } + [DataContract(Name = "historyCleanup", Namespace = "")] + public class HistoryCleanup + { + [DataMember(Name = "preventCleanup")] + public bool PreventCleanup { get; set; } - [DataMember(Name = "keepAllVersionsNewerThanDays")] - public int? KeepAllVersionsNewerThanDays { get;set; } + [DataMember(Name = "keepAllVersionsNewerThanDays")] + public int? KeepAllVersionsNewerThanDays { get;set; } - [DataMember(Name = "keepLatestVersionPerDayForDays")] - public int? KeepLatestVersionPerDayForDays { get;set; } + [DataMember(Name = "keepLatestVersionPerDayForDays")] + public int? KeepLatestVersionPerDayForDays { get;set; } + } } + From 456b8a8a7c7a07a09557f6d83f4cfab9818f9ef5 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 2 Nov 2021 10:58:16 +0100 Subject: [PATCH 2/2] Fixed test now that save of content types creates a cleanup policy --- .../ContentVersionCleanupService_Tests_Integration.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Tests/Services/ContentVersionCleanupService_Tests_Integration.cs b/src/Umbraco.Tests/Services/ContentVersionCleanupService_Tests_Integration.cs index ed177d35c31b..4b795cf5a63e 100644 --- a/src/Umbraco.Tests/Services/ContentVersionCleanupService_Tests_Integration.cs +++ b/src/Umbraco.Tests/Services/ContentVersionCleanupService_Tests_Integration.cs @@ -28,6 +28,11 @@ public void PerformContentVersionCleanup_WithNoKeepPeriods_DeletesEverythingExce // With 11M Property data var contentTypeA = MockedContentTypes.CreateSimpleContentType("contentTypeA", "contentTypeA"); + // Kill all historic + contentTypeA.HistoryCleanup.PreventCleanup = false; + contentTypeA.HistoryCleanup.KeepAllVersionsNewerThanDays = 0; + contentTypeA.HistoryCleanup.KeepLatestVersionPerDayForDays = 0; + ServiceContext.FileService.SaveTemplate(contentTypeA.DefaultTemplate); ServiceContext.ContentTypeService.Save(contentTypeA); @@ -44,8 +49,7 @@ public void PerformContentVersionCleanup_WithNoKeepPeriods_DeletesEverythingExce Debug.Assert(before.ContentVersions == 12); // 10 historic + current draft + current published Debug.Assert(before.PropertyData == 12 * 3); // CreateSimpleContentType = 3 props - // Kill all historic - InsertCleanupPolicy(contentTypeA, 0, 0); + ((IContentVersionService)ServiceContext.ContentService).PerformContentVersionCleanup(DateTime.Now.AddHours(1));