Skip to content

Commit

Permalink
Fix for #619. don't report property deletes as changes when they have… (
Browse files Browse the repository at this point in the history
#621)

* Fix for #619. don't report property deletes as changes when they have already happened

* Add fix for #620 - don't recreate items that are deleted.
  • Loading branch information
KevinJump authored Apr 16, 2024
1 parent 432d74c commit abdc722
Showing 1 changed file with 17 additions and 2 deletions.
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

0 comments on commit abdc722

Please sign in to comment.