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 - delete entries show up twice in report and actions. #617

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion uSync.BackOffice/SyncHandlers/SyncHandlerContainerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ protected override IReadOnlyList<OrderedNodeInfo> GetMergedItems(string[] folder
}

if (renames.Any())
results.AddRange(renames);
{
results.RemoveAll(x => renames.Any(r => r.Key == x.Key));
results.AddRange(renames);
}

return results;
}
Expand Down
11 changes: 10 additions & 1 deletion uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ public IEnumerable<uSyncAction> ImportAll(string folder, HandlerSettings config,
/// </remarks>
public IEnumerable<uSyncAction> ImportAll(string[] folders, HandlerSettings config, uSyncImportOptions options)
{
logger.LogDebug("ImportAll: {handlerType} STARTING", handlerType);

var cacheKey = PrepCaches();
runtimeCache.ClearByKey(cacheKey);

Expand All @@ -280,6 +282,8 @@ public IEnumerable<uSyncAction> ImportAll(string[] folders, HandlerSettings conf
int count = 0;
int total = items.Count;

logger.LogDebug("ImportAll: {handlerType} {count} items", handlerType, total);

foreach (var item in items)
{
count++;
Expand All @@ -296,7 +300,7 @@ public IEnumerable<uSyncAction> ImportAll(string[] folders, HandlerSettings conf
{
cleanMarkers.Add(item.Path);
}
else if (attempt.Item is not null && attempt.Item is TObject update)
else if (attempt.Item is not null && attempt.Item is TObject update && attempt.Change != ChangeType.Hidden)
{
updates.Add(new ImportedItem<TObject>(item.Node,update));
}
Expand All @@ -318,14 +322,17 @@ public IEnumerable<uSyncAction> ImportAll(string[] folders, HandlerSettings conf
serializer.Save(updates.Select(x => x.Item));
}

logger.LogDebug("ImportAll: Second Pass: {handlerType} {updates}", handlerType, updates.Count);
PerformSecondPassImports(updates, actions, config, options.Callbacks?.Update);
}

if (actions.All(x => x.Success) && cleanMarkers.Count > 0)
{
logger.LogDebug("ImportAll: Clean: {handlerType} {cleans}", handlerType, cleanMarkers.Count);
PerformImportClean(cleanMarkers, actions, config, options.Callbacks?.Update);
}

logger.LogDebug("ImportAll: {handlerType} DONE", handlerType);
CleanCaches(cacheKey);
options.Callbacks?.Update?.Invoke("Done", 3, 3);

Expand Down Expand Up @@ -534,6 +541,8 @@ virtual public IEnumerable<uSyncAction> ImportElement(XElement node, string file
var serializerOptions = new SyncSerializerOptions(options.Flags, settings.Settings, options.UserId);
serializerOptions.MergeSettings(options.Settings);

logger.LogDebug("ImportElement: {alias} {path} {filename}", node.GetAlias(), node.GetPath(), shortFilename);

// get the item.
var attempt = DeserializeItem(node, serializerOptions);
var action = uSyncActionHelper<TObject>.SetAction(attempt, GetNameFromFileOrNode(shortFilename, node), node.GetKey(), this.Alias, IsTwoPass);
Expand Down
Loading