Use .Distinct on assembly

pull/3871/head
David Ullmer 4 years ago
parent 025ee2163f
commit 7f79f2ee0e

@ -1387,15 +1387,17 @@ namespace Emby.Server.Implementations
public IEnumerable<Assembly> GetApiPluginAssemblies()
{
var types = _allConcreteTypes
var assemblies = _allConcreteTypes
.Where(i => typeof(ControllerBase).IsAssignableFrom(i))
.Select(i => i.Assembly)
.Distinct();
foreach (var type in types)
foreach (var assembly in assemblies)
{
Logger.LogDebug("Found API endpoints in plugin {name}", type.Assembly.FullName);
yield return type.Assembly;
Logger.LogDebug("Found API endpoints in plugin {name}", assembly.FullName);
}
return assemblies;
}
public virtual void LaunchUrl(string url)

@ -136,9 +136,9 @@ namespace Jellyfin.Server.Extensions
/// </summary>
/// <param name="serviceCollection">The service collection.</param>
/// <param name="baseUrl">The base url for the API.</param>
/// <param name="applicationHost">The application host.</param>
/// <param name="pluginAssemblies">An IEnumberable containing all plugin assemblies with API controllers.</param>
/// <returns>The MVC builder.</returns>
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl, IApplicationHost applicationHost)
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl, IEnumerable<Assembly> pluginAssemblies)
{
IMvcBuilder mvcBuilder = serviceCollection
.AddCors(options =>
@ -179,7 +179,7 @@ namespace Jellyfin.Server.Extensions
options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy;
});
foreach (Assembly pluginAssembly in applicationHost.GetApiPluginAssemblies())
foreach (Assembly pluginAssembly in pluginAssemblies)
{
mvcBuilder.AddApplicationPart(pluginAssembly);
}

@ -41,7 +41,7 @@ namespace Jellyfin.Server
{
services.AddResponseCompression();
services.AddHttpContextAccessor();
services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/'), _applicationHost);
services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/'), _applicationHost.GetApiPluginAssemblies());
services.AddJellyfinApiSwagger();

Loading…
Cancel
Save