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 #619. don't report property deletes as changes when they have… #621

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions uSync.Core/Tracking/SyncRootMergerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Xml.Linq;
using System.Xml.XPath;

using Serilog.Core;

namespace uSync.Core.Tracking;

public class SyncRootMergerHelper
Expand All @@ -26,11 +28,19 @@ public static (XElement combined, XElement differences) CompareNodes(List<XEleme
var differences = XElement.Parse(nodes[^1].ToString());
var combined = XElement.Parse(nodes[^1].ToString());

// latest is a blank one, that is a delete so should
// be marked as one.
if (combined.IsEmptyItem())
return (combined, BlankNode(differences));

foreach (var node in nodes[..^1])
{
// if this node is the same as the differences we already have,
// return it.
if (node.ToString() == differences.ToString())
return (combined, BlankNode(differences));

// workout any merged diffrences,
(combined, differences) = GetTrackedNodeDifferences(node, combined, trackedNodes);
}
return (combined, differences);
Expand Down Expand Up @@ -152,8 +162,13 @@ private static (XElement combined, XElement diffrence) GetMultipleChanges(Tracki
else
{
var replacement = FindByKey(combinedCollection, element, item.Keys, key);
replacement?.AddAfterSelf(targetElement);
replacement?.Remove();

// only add this if its not a delete
if (targetElement.Attribute("deleted").ValueOrDefault(false) is false)
{
replacement?.AddAfterSelf(targetElement);
}
replacement?.Remove();
}
}

Expand Down
Loading