Merge remote-tracking branch 'upstream/master' into development-https

This commit is contained in:
Mark Monteiro
2020-04-01 23:21:30 +02:00
190 changed files with 1246 additions and 818 deletions

View File

@@ -240,11 +240,6 @@ namespace Emby.Server.Implementations
/// </summary>
public int HttpsPort { get; private set; }
/// <summary>
/// Gets the content root for the webhost.
/// </summary>
public string ContentRoot { get; private set; }
/// <summary>
/// Gets the server configuration manager.
/// </summary>
@@ -617,13 +612,7 @@ namespace Emby.Server.Implementations
DiscoverTypes();
await RegisterResources(serviceCollection, startupConfig).ConfigureAwait(false);
ContentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath;
if (string.IsNullOrEmpty(ContentRoot))
{
ContentRoot = ServerConfigurationManager.ApplicationPaths.WebPath;
}
await RegisterServices(serviceCollection, startupConfig).ConfigureAwait(false);
}
public async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func<Task> next)
@@ -654,9 +643,9 @@ namespace Emby.Server.Implementations
}
/// <summary>
/// Registers resources that classes will depend on
/// Registers services/resources with the service collection that will be available via DI.
/// </summary>
protected async Task RegisterResources(IServiceCollection serviceCollection, IConfiguration startupConfig)
protected async Task RegisterServices(IServiceCollection serviceCollection, IConfiguration startupConfig)
{
serviceCollection.AddMemoryCache();
@@ -774,20 +763,8 @@ namespace Emby.Server.Implementations
CertificateInfo = GetCertificateInfo(true);
Certificate = GetCertificate(CertificateInfo);
HttpServer = new HttpListenerHost(
this,
LoggerFactory.CreateLogger<HttpListenerHost>(),
ServerConfigurationManager,
startupConfig,
NetworkManager,
JsonSerializer,
XmlSerializer,
CreateHttpListener())
{
GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading")
};
serviceCollection.AddSingleton(HttpServer);
serviceCollection.AddSingleton<IHttpListener, WebSocketSharpListener>();
serviceCollection.AddSingleton<IHttpServer, HttpListenerHost>();
ImageProcessor = new ImageProcessor(LoggerFactory.CreateLogger<ImageProcessor>(), ServerConfigurationManager.ApplicationPaths, FileSystemManager, ImageEncoder, () => LibraryManager, () => MediaEncoder);
serviceCollection.AddSingleton(ImageProcessor);
@@ -849,10 +826,15 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton<IDeviceDiscovery>(new DeviceDiscovery(ServerConfigurationManager));
ChapterManager = new ChapterManager(LibraryManager, LoggerFactory, ServerConfigurationManager, ItemRepository);
ChapterManager = new ChapterManager(ItemRepository);
serviceCollection.AddSingleton(ChapterManager);
EncodingManager = new MediaEncoder.EncodingManager(FileSystemManager, LoggerFactory, MediaEncoder, ChapterManager, LibraryManager);
EncodingManager = new MediaEncoder.EncodingManager(
LoggerFactory.CreateLogger<MediaEncoder.EncodingManager>(),
FileSystemManager,
MediaEncoder,
ChapterManager,
LibraryManager);
serviceCollection.AddSingleton(EncodingManager);
var activityLogRepo = GetActivityLogRepository();
@@ -895,6 +877,14 @@ namespace Emby.Server.Implementations
((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
}
/// <summary>
/// Create services registered with the service container that need to be initialized at application startup.
/// </summary>
public void InitializeServices()
{
HttpServer = Resolve<IHttpServer>();
}
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
{
// Distinct these to prevent users from reporting problems that aren't actually problems
@@ -1172,7 +1162,7 @@ namespace Emby.Server.Implementations
{
exportedTypes = ass.GetExportedTypes();
}
catch (TypeLoadException ex)
catch (FileNotFoundException ex)
{
Logger.LogError(ex, "Error getting exported types from {Assembly}", ass.FullName);
continue;
@@ -1212,8 +1202,6 @@ namespace Emby.Server.Implementations
});
}
protected IHttpListener CreateHttpListener() => new WebSocketSharpListener(LoggerFactory.CreateLogger<WebSocketSharpListener>());
private CertificateInfo GetCertificateInfo(bool generateCertificate)
{
// Custom cert
@@ -1808,7 +1796,7 @@ namespace Emby.Server.Implementations
}
_userRepository?.Dispose();
_displayPreferencesRepository.Dispose();
_displayPreferencesRepository?.Dispose();
}
_userRepository = null;