Changed IsDocker check (#1998)
* Refactored IsDocker to be completely static and changed to use an environment variable instead. * Removed file from another branch
This commit is contained in:
parent
57a6c769bc
commit
be5b5d9251
10 changed files with 20 additions and 77 deletions
|
@ -15,6 +15,7 @@ using API.Services.Tasks.Scanner;
|
|||
using AutoMapper;
|
||||
using Flurl.Http;
|
||||
using Kavita.Common;
|
||||
using Kavita.Common.EnvironmentInfo;
|
||||
using Kavita.Common.Extensions;
|
||||
using Kavita.Common.Helpers;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
@ -183,6 +184,7 @@ public class SettingsController : BaseApiController
|
|||
|
||||
if (setting.Key == ServerSettingKey.Port && updateSettingsDto.Port + string.Empty != setting.Value)
|
||||
{
|
||||
if (OsInfo.IsDocker) break;
|
||||
setting.Value = updateSettingsDto.Port + string.Empty;
|
||||
// Port is managed in appSetting.json
|
||||
Configuration.Port = updateSettingsDto.Port;
|
||||
|
@ -191,6 +193,7 @@ public class SettingsController : BaseApiController
|
|||
|
||||
if (setting.Key == ServerSettingKey.IpAddresses && updateSettingsDto.IpAddresses != setting.Value)
|
||||
{
|
||||
if (OsInfo.IsDocker) break;
|
||||
// Validate IP addresses
|
||||
foreach (var ipAddress in updateSettingsDto.IpAddresses.Split(','))
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace API.DTOs.Settings;
|
|||
|
||||
public class ServerSettingDto
|
||||
{
|
||||
|
||||
public string CacheDirectory { get; set; } = default!;
|
||||
public string TaskScan { get; set; } = default!;
|
||||
/// <summary>
|
||||
|
|
|
@ -174,7 +174,7 @@ public class Program
|
|||
webBuilder.UseKestrel((opts) =>
|
||||
{
|
||||
var ipAddresses = Configuration.IpAddresses;
|
||||
if (new OsInfo().IsDocker || string.IsNullOrEmpty(ipAddresses) || ipAddresses.Equals(Configuration.DefaultIpAddresses))
|
||||
if (OsInfo.IsDocker || string.IsNullOrEmpty(ipAddresses) || ipAddresses.Equals(Configuration.DefaultIpAddresses))
|
||||
{
|
||||
opts.ListenAnyIP(HttpPort, options => { options.Protocols = HttpProtocols.Http1AndHttp2; });
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public class StatsService : IStatsService
|
|||
Os = RuntimeInformation.OSDescription,
|
||||
KavitaVersion = serverSettings.InstallVersion,
|
||||
DotnetVersion = Environment.Version.ToString(),
|
||||
IsDocker = new OsInfo().IsDocker,
|
||||
IsDocker = OsInfo.IsDocker,
|
||||
NumOfCores = Math.Max(Environment.ProcessorCount, 1),
|
||||
UsersWithEmulateComicBook = await _context.AppUserPreferences.CountAsync(p => p.EmulateBook),
|
||||
TotalReadingHours = await _statisticService.TimeSpentReadingForUsersAsync(ArraySegment<int>.Empty, ArraySegment<int>.Empty),
|
||||
|
|
|
@ -100,7 +100,7 @@ public class VersionUpdaterService : IVersionUpdaterService
|
|||
UpdateBody = _markdown.Transform(update.Body.Trim()),
|
||||
UpdateTitle = update.Name,
|
||||
UpdateUrl = update.Html_Url,
|
||||
IsDocker = new OsInfo(Array.Empty<IOsVersionAdapter>()).IsDocker,
|
||||
IsDocker = OsInfo.IsDocker,
|
||||
PublishDate = update.Published_At
|
||||
};
|
||||
}
|
||||
|
|
|
@ -415,7 +415,9 @@ public class Startup
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if ((ex.Message.Contains("Permission denied") || ex.Message.Contains("UnauthorizedAccessException")) && baseUrl.Equals(Configuration.DefaultBaseUrl) && new OsInfo().IsDocker)
|
||||
if ((ex.Message.Contains("Permission denied")
|
||||
|| ex.Message.Contains("UnauthorizedAccessException"))
|
||||
&& baseUrl.Equals(Configuration.DefaultBaseUrl) && OsInfo.IsDocker)
|
||||
{
|
||||
// Swallow the exception as the install is non-root and Docker
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue