aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Program.cs
diff options
context:
space:
mode:
authorMark Monteiro <marknr.monteiro@protonmail.com>2020-02-25 16:51:36 +0100
committerMark Monteiro <marknr.monteiro@protonmail.com>2020-02-25 16:51:36 +0100
commit26af5ea45a8ea02b7a3f20b0ebc31ef19f850dea (patch)
tree1bc3cfcd4a38ca1827847cc13ca66081b31a84da /Jellyfin.Server/Program.cs
parentf11678ae4b1d3294c467ee62b16f4b2bc4a64e0d (diff)
Do not set a static content root if the jellyfin-web directory does not exist or is empty
Diffstat (limited to 'Jellyfin.Server/Program.cs')
-rw-r--r--Jellyfin.Server/Program.cs20
1 files changed, 17 insertions, 3 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 1dd598236..2ce7379fb 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -222,7 +222,7 @@ namespace Jellyfin.Server
private 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 DI
services.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-web
var 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