mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 06:18:28 +01:00
added IServerEntryPoint to replace plugin.initialize
This commit is contained in:
@@ -183,7 +183,7 @@ namespace MediaBrowser.Controller
|
||||
/// <summary>
|
||||
/// Composes the parts with ioc container.
|
||||
/// </summary>
|
||||
protected override void FindParts()
|
||||
protected void FindParts()
|
||||
{
|
||||
// For now there's no real way to inject this properly
|
||||
BaseItem.LibraryManager = ApplicationHost.Resolve<ILibraryManager>();
|
||||
@@ -194,8 +194,6 @@ namespace MediaBrowser.Controller
|
||||
ProviderManager = (ProviderManager)ApplicationHost.CreateInstance(typeof(ProviderManager));
|
||||
SecurityManager = (PluginSecurityManager)ApplicationHost.CreateInstance(typeof(PluginSecurityManager));
|
||||
|
||||
base.FindParts();
|
||||
|
||||
UserDataRepositories = ApplicationHost.GetExports<IUserDataRepository>();
|
||||
UserRepositories = ApplicationHost.GetExports<IUserRepository>();
|
||||
DisplayPreferencesRepositories = ApplicationHost.GetExports<IDisplayPreferencesRepository>();
|
||||
@@ -211,15 +209,24 @@ namespace MediaBrowser.Controller
|
||||
/// Performs initializations that can be reloaded at anytime
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
protected override async Task ReloadInternal()
|
||||
protected override async void ReloadInternal()
|
||||
{
|
||||
await base.ReloadInternal().ConfigureAwait(false);
|
||||
base.ReloadInternal();
|
||||
|
||||
FindParts();
|
||||
|
||||
await LoadRepositories().ConfigureAwait(false);
|
||||
|
||||
ReloadResourcePools();
|
||||
|
||||
ReloadFileSystemManager();
|
||||
|
||||
await ApplicationHost.Resolve<IUserManager>().RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
foreach (var entryPoint in ApplicationHost.GetExports<IServerEntryPoint>())
|
||||
{
|
||||
entryPoint.Run();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -263,11 +270,8 @@ namespace MediaBrowser.Controller
|
||||
/// Called when [composable parts loaded].
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
protected override async Task OnComposablePartsLoaded()
|
||||
protected Task LoadRepositories()
|
||||
{
|
||||
// The base class will start up all the plugins
|
||||
await base.OnComposablePartsLoaded().ConfigureAwait(false);
|
||||
|
||||
// Get the current item repository
|
||||
ItemRepository = GetRepository(ItemRepositories, Configuration.ItemRepository);
|
||||
var itemRepoTask = ItemRepository.Initialize();
|
||||
@@ -284,7 +288,7 @@ namespace MediaBrowser.Controller
|
||||
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, Configuration.DisplayPreferencesRepository);
|
||||
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
|
||||
|
||||
await Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask).ConfigureAwait(false);
|
||||
return Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
<Compile Include="Persistence\IUserRepository.cs" />
|
||||
<Compile Include="Library\IIntroProvider.cs" />
|
||||
<Compile Include="Plugins\IPluginConfigurationPage.cs" />
|
||||
<Compile Include="Plugins\IServerEntryPoint.cs" />
|
||||
<Compile Include="Plugins\PluginSecurityManager.cs" />
|
||||
<Compile Include="Providers\FanartBaseProvider.cs" />
|
||||
<Compile Include="Providers\IImageEnhancer.cs" />
|
||||
|
||||
15
MediaBrowser.Controller/Plugins/IServerEntryPoint.cs
Normal file
15
MediaBrowser.Controller/Plugins/IServerEntryPoint.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Plugins
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IServerEntryPoint
|
||||
/// </summary>
|
||||
public interface IServerEntryPoint : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Runs this instance.
|
||||
/// </summary>
|
||||
void Run();
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ namespace MediaBrowser.Controller.Updates
|
||||
{
|
||||
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var plugins = Kernel.Plugins;
|
||||
var plugins = ApplicationHost.Plugins;
|
||||
|
||||
if (withAutoUpdateEnabled)
|
||||
{
|
||||
@@ -424,7 +424,7 @@ namespace MediaBrowser.Controller.Updates
|
||||
if (!(Path.GetExtension(package.targetFilename) ?? "").Equals(".zip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Set last update time if we were installed before
|
||||
var plugin = Kernel.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase));
|
||||
var plugin = ApplicationHost.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (plugin != null)
|
||||
{
|
||||
@@ -460,7 +460,7 @@ namespace MediaBrowser.Controller.Updates
|
||||
plugin.OnUninstalling();
|
||||
|
||||
// Remove it the quick way for now
|
||||
Kernel.RemovePlugin(plugin);
|
||||
ApplicationHost.RemovePlugin(plugin);
|
||||
|
||||
File.Delete(plugin.AssemblyFilePath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user