Skip to content

Commit

Permalink
cater for "clean" files.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Apr 30, 2024
1 parent 9dcdd58 commit 5fb73be
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions uSync.BackOffice/Services/SyncFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

using Org.BouncyCastle.Crypto.Engines;

using Umbraco.Cms.Core.Extensions;
using Umbraco.Extensions;

Expand Down Expand Up @@ -492,6 +494,8 @@ public IEnumerable<OrderedNodeInfo> MergeFolders(string[] folders, string extens
{
var elements = new Dictionary<string, OrderedNodeInfo>();

var cleanElements = new Dictionary<string, OrderedNodeInfo>();

foreach (var folder in folders)
{
var absPath = GetAbsPath(folder);
Expand All @@ -516,9 +520,18 @@ public IEnumerable<OrderedNodeInfo> MergeFolders(string[] folders, string extens
}
else
{
// empty if its anything but a delete we ignore it.
// renames are just markers to make sure they don't leave things on disk.
continue;
if (item.Value.Node.GetEmptyAction() == SyncActionType.Clean)
{
// cleans are added, these run a clean up at the end, so if they exist
// we need to add them, but they can clash in terms of keys.
_ = cleanElements.TryAdd(item.Key, item.Value);
}
else
{
// empty if its anything but a delete we ignore it.
// renames are just markers to make sure they don't leave things on disk.
continue;
}
}

if (elements.TryGetValue(item.Key, out var value))
Expand All @@ -532,7 +545,7 @@ public IEnumerable<OrderedNodeInfo> MergeFolders(string[] folders, string extens
}
}

return elements.Values;
return [..elements.Values, ..cleanElements.Values];
}

/// <summary>
Expand Down

0 comments on commit 5fb73be

Please sign in to comment.