diff --git a/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs b/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
index a683c9f2..722250a0 100644
--- a/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
+++ b/uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
@@ -1614,7 +1614,8 @@ protected virtual void ExportDeletedItem(TObject item, string[] folders, Handler
// don't do anything this thing exists at a higher level. !
return;
}
-
+
+ if (ShouldExportDeletedFile(item, config) is false) return;
var attempt = serializer.SerializeEmpty(item, SyncActionType.Delete, string.Empty);
if (ShouldExport(attempt.Item, config))
@@ -1634,10 +1635,24 @@ protected virtual void ExportDeletedItem(TObject item, string[] folders, Handler
}
}
- ///
- /// get all the possible folders for this handlers
- ///
- protected string[] GetDefaultHandlerFolders()
+ 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;
+ }
+ }
+
+ ///
+ /// get all the possible folders for this handlers
+ ///
+ protected string[] GetDefaultHandlerFolders()
=> rootFolders.Select(f => Path.Combine(f, DefaultFolder)).ToArray();