The Free Software Media System - Server Backend & API
Do not call UseContentRoot() on the web host builder
Mark Monteiro05ab61200a18
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.csindex 8bcd087452..bc47817438 100644--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs@@ -1,8 +1,6 @@using System;using System.IO;using MediaBrowser.Common.Configuration;-using MediaBrowser.Controller.Extensions;-using Microsoft.Extensions.Configuration;namespace Emby.Server.Implementations.AppBase{@@ -39,13 +37,7 @@ namespace Emby.Server.Implementations.AppBase/// <value>The program data path.</value>public string ProgramDataPath { get; }- /// <summary>- /// Gets the path to the web UI resources folder.- /// </summary>- /// <value>The web UI resources path.</value>- /// <remarks>- /// This value is not relevant if <see cref="ConfigurationExtensions.IsNoWebContent(IConfiguration)"/> is true.- /// </remarks>+ /// <inheritdoc/>public string WebPath { get; }/// <summary>diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 7262268a97..52c5176271 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -236,11 +236,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>@@ -614,12 +609,6 @@ namespace Emby.Server.ImplementationsDiscoverTypes();await RegisterServices(serviceCollection, startupConfig).ConfigureAwait(false);-- ContentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath;- if (string.IsNullOrEmpty(ContentRoot))- {- ContentRoot = ServerConfigurationManager.ApplicationPaths.WebPath;- }}public async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func<Task> next)diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.csindex bfb2fc6b57..67251eb249 100644--- a/Jellyfin.Server/Program.cs+++ b/Jellyfin.Server/Program.cs@@ -243,7 +243,7 @@ namespace Jellyfin.ServerIConfiguration startupConfig,IApplicationPaths appPaths){- var webhostBuilder = new WebHostBuilder()+ return new WebHostBuilder().UseKestrel(options =>{var addresses = appHost.ServerConfigurationManager@@ -289,24 +289,6 @@ namespace Jellyfin.Serverservices.TryAdd(serviceCollection);}).UseStartup<Startup>();-- // Set up static content hosting unless it has been disabled via config- if (!startupConfig.NoWebContent())- {- // Fail startup if the web content does not exist- if (!Directory.Exists(appHost.ContentRoot) || !Directory.GetFiles(appHost.ContentRoot).Any())- {- throw new InvalidOperationException(- "The server is expected to host web content, but the provided content directory is either " +- $"invalid or empty: {appHost.ContentRoot}. If you do not want to host web content with the " +- $"server, you may set the '{MediaBrowser.Controller.Extensions.ConfigurationExtensions.NoWebContentKey}' flag.");- }-- // Configure the web host to host the static web content- webhostBuilder.UseContentRoot(appHost.ContentRoot);- }-- return webhostBuilder;}/// <summary>diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.csindex 5bdea7d8b3..870b90796c 100644--- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs+++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs@@ -1,3 +1,5 @@+using MediaBrowser.Model.Configuration;+namespace MediaBrowser.Common.Configuration{/// <summary>@@ -12,9 +14,12 @@ namespace MediaBrowser.Common.Configurationstring ProgramDataPath { get; }/// <summary>- /// Gets the path to the web UI resources folder+ /// Gets the path to the web UI resources folder./// </summary>- /// <value>The web UI resources path.</value>+ /// <remarks>+ /// This value is not relevant if the server is configured to not host any static web content. Additionally,+ /// the value for <see cref="ServerConfiguration.DashboardSourcePath"/> takes precedence over this one.+ /// </remarks>string WebPath { get; }/// <summary>diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.csindex 11901c25fb..0114f5d602 100644--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs@@ -136,6 +136,17 @@ namespace MediaBrowser.WebDashboard.Api_resultFactory = resultFactory;_resourceFileManager = resourceFileManager;_appConfig = appConfig;++ // Validate web content path+ string webContentPath = DashboardUIPath;+ bool webContentPathValid = appConfig.NoWebContent() || (Directory.Exists(webContentPath) && Directory.GetFiles(webContentPath).Any());+ if (!webContentPathValid)+ {+ throw new InvalidOperationException(+ "The server is expected to host web content, but the provided content directory is either " ++ $"invalid or empty: {webContentPath}. If you do not want to host web content with the server, " ++ $"you may set the '{Controller.Extensions.ConfigurationExtensions.NoWebContentKey}' flag.");+ }}/// <summary>