From 9dcdd580aab5f8c8334e7850fabb3ee78ba929a4 Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Tue, 30 Apr 2024 18:12:47 +0100 Subject: [PATCH] Fix #635 - stop renames from entering the duplicate check. --- uSync.BackOffice/Services/SyncFileService.cs | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/uSync.BackOffice/Services/SyncFileService.cs b/uSync.BackOffice/Services/SyncFileService.cs index 8200c917..54efa059 100644 --- a/uSync.BackOffice/Services/SyncFileService.cs +++ b/uSync.BackOffice/Services/SyncFileService.cs @@ -505,16 +505,26 @@ public IEnumerable 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)}"; }