Skip to content

Commit

Permalink
fix for when only a single folder is passed to the handler methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Apr 22, 2024
1 parent 6f9c21a commit 8320b63
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions uSync.BackOffice/Services/uSyncService_Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ namespace uSync.BackOffice

public partial class uSyncService
{
private string[] GetFolderFromOptions(uSyncImportOptions options)
{
if (options.Folders?.Any() is true)
return options.Folders;

if (string.IsNullOrWhiteSpace(options.RootFolder) is false)
return [options.RootFolder];

// return the default.
return _uSyncConfig.GetFolders();
}

/// <summary>
/// Run a report for a given handler
/// </summary>
Expand All @@ -29,8 +41,8 @@ public IEnumerable<uSyncAction> ReportHandler(string handler, uSyncImportOptions
Action = HandlerActions.Report
});

if (handlerPair == null) return Enumerable.Empty<uSyncAction>();
var folders = GetHandlerFolders(options.Folders, handlerPair.Handler);
if (handlerPair == null) return [];
var folders = GetHandlerFolders(GetFolderFromOptions(options), handlerPair.Handler);

return handlerPair.Handler.Report(folders, handlerPair.Settings, options.Callbacks?.Update);
}
Expand All @@ -50,8 +62,8 @@ public IEnumerable<uSyncAction> ImportHandler(string handlerAlias, uSyncImportOp
Action = HandlerActions.Import
});

if (handlerPair == null) return Enumerable.Empty<uSyncAction>();
var folders = GetHandlerFolders(options.Folders, handlerPair.Handler);
if (handlerPair == null) return [];
var folders = GetHandlerFolders(GetFolderFromOptions(options), handlerPair.Handler);

using var scope = _scopeProvider.CreateNotificationScope(
eventAggregator: _eventAggregator,
Expand Down Expand Up @@ -103,8 +115,9 @@ public IEnumerable<uSyncAction> ExportHandler(string handler, uSyncImportOptions
Action = HandlerActions.Export
});

if (handlerPair == null) return Enumerable.Empty<uSyncAction>();
var folders = GetHandlerFolders(options.Folders, handlerPair.Handler);
if (handlerPair == null) return [];

var folders = GetHandlerFolders(GetFolderFromOptions(options), handlerPair.Handler);
return handlerPair.Handler.ExportAll(folders, handlerPair.Settings, options.Callbacks?.Update);
}

Expand Down

0 comments on commit 8320b63

Please sign in to comment.