The Free Software Media System - Server Backend & API
Do not set a static content root if the jellyfin-web directory does not exist or is empty
Mark Monteiro26af5ea45a8e
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.csindex c3cdcc2222..be2d198efc 100644--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs@@ -40,7 +40,7 @@ namespace Emby.Server.Implementations.AppBase/// <summary>/// Gets the path to the web UI resources folder./// </summary>- /// <value>The web UI resources path.</value>+ /// <value>The web UI resources path, or null if the server is not hosting any web content.</value>public string WebPath { get; }/// <summary>diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 8ea188724a..a5b88f64f2 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -240,7 +240,7 @@ namespace Emby.Server.Implementationspublic int HttpsPort { get; private set; }/// <summary>- /// Gets the content root for the webhost.+ /// Gets the content root for the webhost. If the webhost is not serving static web content, this will be null./// </summary>public string ContentRoot { get; private set; }diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.csindex 1dd598236b..2ce7379fba 100644--- a/Jellyfin.Server/Program.cs+++ b/Jellyfin.Server/Program.cs@@ -222,7 +222,7 @@ namespace Jellyfin.Serverprivate static IWebHostBuilder CreateWebHostBuilder(ApplicationHost appHost, IServiceCollection serviceCollection){- return new WebHostBuilder()+ var webhostBuilder = new WebHostBuilder().UseKestrel(options =>{var addresses = appHost.ServerConfigurationManager@@ -260,13 +260,20 @@ namespace Jellyfin.Server}}})- .UseContentRoot(appHost.ContentRoot).ConfigureServices(services =>{// Merge the external ServiceCollection into ASP.NET DIservices.TryAdd(serviceCollection);}).UseStartup<Startup>();++ // Set the root directory for static content, if one exists+ if (!string.IsNullOrEmpty(appHost.ContentRoot))+ {+ webhostBuilder.UseContentRoot(appHost.ContentRoot);+ }++ return webhostBuilder;}/// <summary>@@ -383,7 +390,7 @@ namespace Jellyfin.Server// webDir// IF --webdir// ELSE IF $JELLYFIN_WEB_DIR- // ELSE use <bindir>/jellyfin-web+ // ELSE <bindir>/jellyfin-webvar webDir = options.WebDir;if (string.IsNullOrEmpty(webDir))@@ -397,6 +404,13 @@ namespace Jellyfin.Server}}+ // Reset webDir if the directory does not exist, or is empty+ if (!Directory.Exists(webDir) || !Directory.GetFiles(webDir).Any())+ {+ _logger.LogInformation("Server will not host static content because the web content directory does not exist or is empty: {ContentRoot}", webDir);+ webDir = null;+ }+// logDir// IF --logdir// ELSE IF $JELLYFIN_LOG_DIR