From 2ea5c21786e5aa36b98d1929e2398b13b3bd21b9 Mon Sep 17 00:00:00 2001 From: henryjump <140804846+henryjump@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:03:09 +0100 Subject: [PATCH] moved more deletes to end of process --- .../SyncHandlers/SyncHandlerContainerBase.cs | 13 ++++++++++++- .../Serialization/SyncContainerSerializerBase.cs | 13 +++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs b/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs index 3cf64595..c1e71172 100644 --- a/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs +++ b/uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs @@ -120,7 +120,18 @@ public virtual IEnumerable ProcessPostImport(IEnumerable(); - return CleanFolders(-1); + var results = new List(); + + // we only do deletes here. + foreach (var action in actions.Where(x => x.Change == ChangeType.Hidden)) + { + results.AddRange( + Import(action.FileName, config, SerializerFlags.LastPass)); + } + + results.AddRange(CleanFolders(-1)); + + return results; } /// diff --git a/uSync.Core/Serialization/SyncContainerSerializerBase.cs b/uSync.Core/Serialization/SyncContainerSerializerBase.cs index 63bb143a..8515e643 100644 --- a/uSync.Core/Serialization/SyncContainerSerializerBase.cs +++ b/uSync.Core/Serialization/SyncContainerSerializerBase.cs @@ -11,6 +11,7 @@ using Umbraco.Cms.Core.Models.Entities; using Umbraco.Cms.Core.Services; using Umbraco.Extensions; +using uSync.Core.Models; namespace uSync.Core.Serialization { @@ -26,6 +27,18 @@ public SyncContainerSerializerBase(IEntityService entityService, ILogger ProcessDelete(Guid key, string alias, SerializerFlags flags) + { + if (flags.HasFlag(SerializerFlags.LastPass)) + { + logger.LogDebug("Processing deletes as part of the last pass"); + return base.ProcessDelete(key, alias, flags); + } + + logger.LogDebug("Delete not processing as this is not the final pass"); + return SyncAttempt.Succeed(alias, ChangeType.Hidden); + } + protected override Attempt FindOrCreate(XElement node) {