Skip to content

Commit

Permalink
Fix #635 - stop renames from entering the duplicate check.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Apr 30, 2024
1 parent 3fb6797 commit 9dcdd58
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions uSync.BackOffice/Services/SyncFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,26 @@ public IEnumerable<OrderedNodeInfo> MergeFolders(string[] folders, string extens
foreach (var item in items)
{
var itemKey = item.Value.Node.GetKey();
if (localKeys.Contains(itemKey) && item.Value.Node.IsEmptyItem() is false) {
throw new Exception($"Duplicate: Item key {itemKey} already exists for {item.Key} - run uSync Health check for more info.");
}
if (item.Value.Node.IsEmptyItem() is false || item.Value.Node.GetEmptyAction() == SyncActionType.Delete)
{
if (localKeys.Contains(itemKey))
{
throw new Exception($"Duplicate: Item key {itemKey} already exists for {item.Key} - run uSync Health check for more info.");
}

localKeys.Add(itemKey);
localKeys.Add(itemKey);
}
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.ContainsKey(item.Key))
if (elements.TryGetValue(item.Key, out var value))
{
// merge these files.
item.Value.SetNode(MergeNodes(elements[item.Key].Node, item.Value.Node, trackerBase));
item.Value.SetNode(MergeNodes(value.Node, item.Value.Node, trackerBase));
item.Value.FileName = $"{uSyncConstants.MergedFolderName}/{Path.GetFileName(item.Value.FileName)}";
}

Expand Down

0 comments on commit 9dcdd58

Please sign in to comment.