Merge branch 'master' into network-rewrite
This commit is contained in:
+10
-21
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -201,7 +202,7 @@ namespace Jellyfin.Server
|
||||
{
|
||||
await webHost.StartAsync(_tokenSource.Token).ConfigureAwait(false);
|
||||
|
||||
if (startupConfig.UseUnixSocket() && Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
if (!OperatingSystem.IsWindows() && startupConfig.UseUnixSocket())
|
||||
{
|
||||
var socketPath = GetUnixSocketPath(startupConfig, appPaths);
|
||||
|
||||
@@ -234,7 +235,7 @@ namespace Jellyfin.Server
|
||||
finally
|
||||
{
|
||||
// Don't throw additional exception if startup failed.
|
||||
if (appHost.ServiceProvider != null)
|
||||
if (appHost.ServiceProvider is not null)
|
||||
{
|
||||
_logger.LogInformation("Running query planner optimizations in the database... This might take a while");
|
||||
// Run before disposing the application
|
||||
@@ -400,7 +401,7 @@ namespace Jellyfin.Server
|
||||
|
||||
if (string.IsNullOrEmpty(configDir))
|
||||
{
|
||||
if (options.DataDir != null
|
||||
if (options.DataDir is not null
|
||||
|| Directory.Exists(Path.Combine(dataDir, "config"))
|
||||
|| OperatingSystem.IsWindows())
|
||||
{
|
||||
@@ -575,7 +576,7 @@ namespace Jellyfin.Server
|
||||
{
|
||||
// Use the swagger API page as the default redirect path if not hosting the web client
|
||||
var inMemoryDefaultConfig = ConfigurationOptions.DefaultConfiguration;
|
||||
if (startupConfig != null && !startupConfig.HostWebClient())
|
||||
if (startupConfig is not null && !startupConfig.HostWebClient())
|
||||
{
|
||||
inMemoryDefaultConfig[DefaultRedirectKey] = "api-docs/swagger";
|
||||
}
|
||||
@@ -635,7 +636,7 @@ namespace Jellyfin.Server
|
||||
}
|
||||
|
||||
string commandLineArgsString;
|
||||
if (options.RestartArgs != null)
|
||||
if (options.RestartArgs is not null)
|
||||
{
|
||||
commandLineArgsString = options.RestartArgs;
|
||||
}
|
||||
@@ -670,7 +671,7 @@ namespace Jellyfin.Server
|
||||
{
|
||||
var xdgRuntimeDir = Environment.GetEnvironmentVariable("XDG_RUNTIME_DIR");
|
||||
var socketFile = "jellyfin.sock";
|
||||
if (xdgRuntimeDir == null)
|
||||
if (xdgRuntimeDir is null)
|
||||
{
|
||||
// Fall back to config dir
|
||||
socketPath = Path.Join(appPaths.ConfigurationDirectoryPath, socketFile);
|
||||
@@ -684,27 +685,15 @@ namespace Jellyfin.Server
|
||||
return socketPath;
|
||||
}
|
||||
|
||||
[UnsupportedOSPlatform("windows")]
|
||||
private static void SetUnixSocketPermissions(IConfiguration startupConfig, string socketPath)
|
||||
{
|
||||
var socketPerms = startupConfig.GetUnixSocketPermissions();
|
||||
|
||||
if (!string.IsNullOrEmpty(socketPerms))
|
||||
{
|
||||
#pragma warning disable SA1300 // Entrypoint is case sensitive.
|
||||
[DllImport("libc")]
|
||||
static extern int chmod(string pathname, int mode);
|
||||
#pragma warning restore SA1300
|
||||
|
||||
var exitCode = chmod(socketPath, Convert.ToInt32(socketPerms, 8));
|
||||
|
||||
if (exitCode < 0)
|
||||
{
|
||||
_logger.LogError("Failed to set Kestrel unix socket permissions to {SocketPerms}, return code: {ExitCode}", socketPerms, exitCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Kestrel unix socket permissions set to {SocketPerms}", socketPerms);
|
||||
}
|
||||
File.SetUnixFileMode(socketPath, (UnixFileMode)Convert.ToInt32(socketPerms, 8));
|
||||
_logger.LogInformation("Kestrel unix socket permissions set to {SocketPerms}", socketPerms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user