mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Move check for web client directory to application startup in Program.cs
This commit is contained in:
parent
4bccaafb57
commit
ca85bef7c5
@ -20,6 +20,7 @@ using Jellyfin.Drawing.Skia;
|
|||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Drawing;
|
using MediaBrowser.Controller.Drawing;
|
||||||
using MediaBrowser.Controller.Extensions;
|
using MediaBrowser.Controller.Extensions;
|
||||||
|
using MediaBrowser.WebDashboard.Api;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@ -185,8 +186,23 @@ namespace Jellyfin.Server
|
|||||||
new ManagedFileSystem(_loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths),
|
new ManagedFileSystem(_loggerFactory.CreateLogger<ManagedFileSystem>(), appPaths),
|
||||||
GetImageEncoder(appPaths),
|
GetImageEncoder(appPaths),
|
||||||
new NetworkManager(_loggerFactory.CreateLogger<NetworkManager>()));
|
new NetworkManager(_loggerFactory.CreateLogger<NetworkManager>()));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// If hosting the web client, validate the client content path
|
||||||
|
if (startupConfig.HostWebClient())
|
||||||
|
{
|
||||||
|
string webContentPath = DashboardService.GetDashboardUIPath(startupConfig, appHost.ServerConfigurationManager);
|
||||||
|
if (!Directory.Exists(webContentPath) || Directory.GetFiles(webContentPath).Length == 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"The server is expected to host the web client, but the provided content directory is either " +
|
||||||
|
$"invalid or empty: {webContentPath}. If you do not want to host the web client with the " +
|
||||||
|
"server, you may set the '--nowebclient' command line flag, or set" +
|
||||||
|
$"'{MediaBrowser.Controller.Extensions.ConfigurationExtensions.HostWebClientKey}=false' in your config settings.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServiceCollection serviceCollection = new ServiceCollection();
|
ServiceCollection serviceCollection = new ServiceCollection();
|
||||||
await appHost.InitAsync(serviceCollection, startupConfig).ConfigureAwait(false);
|
await appHost.InitAsync(serviceCollection, startupConfig).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -161,22 +161,27 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
/// Gets the path of the directory containing the static web interface content, or null if the server is not
|
/// Gets the path of the directory containing the static web interface content, or null if the server is not
|
||||||
/// hosting the web client.
|
/// hosting the web client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DashboardUIPath
|
public string DashboardUIPath => GetDashboardUIPath(_appConfig, _serverConfigurationManager);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the path of the directory containing the static web interface content.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appConfig">The app configuration.</param>
|
||||||
|
/// <param name="serverConfigManager">The server configuration manager.</param>
|
||||||
|
/// <returns>The directory path, or null if the server is not hosting the web client.</returns>
|
||||||
|
public static string GetDashboardUIPath(IConfiguration appConfig, IServerConfigurationManager serverConfigManager)
|
||||||
{
|
{
|
||||||
get
|
if (!appConfig.HostWebClient())
|
||||||
{
|
|
||||||
if (!_appConfig.HostWebClient())
|
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(_serverConfigurationManager.Configuration.DashboardSourcePath))
|
if (!string.IsNullOrEmpty(serverConfigManager.Configuration.DashboardSourcePath))
|
||||||
{
|
{
|
||||||
return _serverConfigurationManager.Configuration.DashboardSourcePath;
|
return serverConfigManager.Configuration.DashboardSourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _serverConfigurationManager.ApplicationPaths.WebPath;
|
return serverConfigManager.ApplicationPaths.WebPath;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user