Skip to content

Commit

Permalink
Use suppression of notifications if configured
Browse files Browse the repository at this point in the history
  • Loading branch information
ljfio committed Apr 10, 2024
1 parent b14a9e9 commit 4379e8e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
9 changes: 3 additions & 6 deletions uSync.BackOffice/Configuration/uSyncSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,11 @@ public class uSyncSettings

/// <summary>
/// turns of use of the Notifications.Supress method, so notifications
/// fire after every item is imported.
/// are suppressed during the import
/// </summary>
/// <remarks>
/// I am not sure this does what i think it does, it doesn't suppress
/// then fire at the end , it just suppresses them all.
///
/// until we have had time to look at this , we will leave this as
/// disabled by default so all notification messages fire.
/// this will result in no notifications being fired througout the import,
/// use this if you are comfortable with the risks
/// </remarks>
[DefaultValue("false")]
public bool DisableNotificationSuppression { get; set; } = false;
Expand Down
2 changes: 2 additions & 0 deletions uSync.BackOffice/Services/uSyncService_Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public IEnumerable<uSyncAction> ImportHandler(string handlerAlias, uSyncImportOp
backgroundTaskQueue: _backgroundTaskQueue,
options.Callbacks?.Update);

using var supression = scope.SuppressScopeByConfig(_uSyncConfig);

var results = handlerPair.Handler.ImportAll(folders, handlerPair.Settings, options);

_logger.LogDebug("< Import Handler {handler}", handlerAlias);
Expand Down
8 changes: 6 additions & 2 deletions uSync.BackOffice/Services/uSyncService_Single.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,16 @@ public IEnumerable<uSyncAction> ImportPartial(IList<OrderedNodeInfo> orderedNode

var index = options.PageNumber * options.PageSize;

using var scope = _scopeProvider.CreateNotificationScope(
using (var scope = _scopeProvider.CreateNotificationScope(
eventAggregator: _eventAggregator,
loggerFactory: _loggerFactory,
syncConfigService: _uSyncConfig,
syncEventService: _mutexService,
backgroundTaskQueue: _backgroundTaskQueue,
options.Callbacks?.Update);
options.Callbacks?.Update))
{
using var suppression = scope.SuppressScopeByConfig(_uSyncConfig);

try
{
foreach (var item in orderedNodes.Skip(options.PageNumber * options.PageSize).Take(options.PageSize))
Expand Down Expand Up @@ -209,6 +211,8 @@ public IEnumerable<uSyncAction> ImportPartialSecondPass(IEnumerable<uSyncAction>
backgroundTaskQueue: _backgroundTaskQueue,
options.Callbacks?.Update))
{
using var suppression = scope.SuppressScopeByConfig(_uSyncConfig);

try
{
foreach (var action in actions.Skip(options.PageNumber * options.PageSize).Take(options.PageSize))
Expand Down

0 comments on commit 4379e8e

Please sign in to comment.