Skip to content

Commit

Permalink
From v13: fix #605 - check delete by serializing item one last time. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Apr 17, 2024
1 parent b8b0d2e commit 4beb294
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ protected virtual void ExportDeletedItem(TObject item, string[] folders, Handler
return;
}

if (ShouldExportDeletedFile(item, config) is false) return;

var attempt = serializer.SerializeEmpty(item, SyncActionType.Delete, string.Empty);
if (attempt.Item is not null && ShouldExport(attempt.Item, config) is true)
Expand All @@ -1640,6 +1641,20 @@ protected virtual void ExportDeletedItem(TObject item, string[] folders, Handler
}
}

private bool ShouldExportDeletedFile(TObject item, HandlerSettings config)
{
try
{
var deletingAttempt = serializer.Serialize(item, new SyncSerializerOptions(config.Settings));
return ShouldExport(deletingAttempt.Item, config);
}
catch (Exception ex)
{
logger.LogWarning(ex, "Failed to calculate if this item should be exported when deleted, the common option is yes, so we will");
return true;
}
}

/// <summary>
/// get all the possible folders for this handlers
/// </summary>
Expand Down

0 comments on commit 4beb294

Please sign in to comment.