mirror of https://github.com/Jackett/Jackett
Attempt to handle not found System.Runtime.InteropServices.RuntimeInformation
https://github.com/Jackett/Jackett/issues/3816
This commit is contained in:
parent
2f378210d9
commit
f9b4b5a76c
|
@ -10,7 +10,6 @@ using NLog;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Jackett.Common.Models.IndexerConfig.ConfigurationData;
|
||||
|
@ -177,10 +176,9 @@ namespace Jackett.Common.Indexers
|
|||
//TODO: Remove this section once users have moved off DPAPI
|
||||
private bool MigratedFromDPAPI(JToken jsonConfig)
|
||||
{
|
||||
bool runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("core", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;
|
||||
|
||||
if (!isWindows && runningOnDotNetCore)
|
||||
if (!isWindows && DotNetCoreUtil.IsRunningOnDotNetCore)
|
||||
{
|
||||
// User isn't running Windows, but is running on .NET Core framework, no access to the DPAPI, so don't bother trying to migrate
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Jackett.Common.Utils
|
||||
{
|
||||
public static class DotNetCoreUtil
|
||||
{
|
||||
public static bool IsRunningOnDotNetCore
|
||||
{
|
||||
get
|
||||
{
|
||||
bool runningOnDotNetCore = false;
|
||||
|
||||
try
|
||||
{
|
||||
runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("core", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Issue only appears to occur for small number of users on Mono
|
||||
runningOnDotNetCore = false;
|
||||
}
|
||||
|
||||
return runningOnDotNetCore;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,8 +4,6 @@ using Jackett.Common.Utils;
|
|||
using Jackett.Server.Services;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Jackett.Server
|
||||
{
|
||||
|
@ -113,8 +111,8 @@ namespace Jackett.Server
|
|||
{
|
||||
logger.Info("Overriding port to " + consoleOptions.Port);
|
||||
serverConfig.Port = consoleOptions.Port;
|
||||
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
if (isWindows)
|
||||
|
||||
if (EnvironmentUtil.IsWindows)
|
||||
{
|
||||
if (ServerUtil.IsUserAdministrator())
|
||||
{
|
||||
|
@ -137,7 +135,7 @@ namespace Jackett.Server
|
|||
{
|
||||
logger.Info("Overriding external access to " + consoleOptions.ListenPublic);
|
||||
serverConfig.AllowExternal = consoleOptions.ListenPublic;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (EnvironmentUtil.IsWindows)
|
||||
{
|
||||
if (ServerUtil.IsUserAdministrator())
|
||||
{
|
||||
|
|
|
@ -47,9 +47,7 @@ namespace Jackett.Server
|
|||
{
|
||||
if (string.IsNullOrEmpty(options.Client))
|
||||
{
|
||||
bool runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("Core", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
|
||||
if (runningOnDotNetCore)
|
||||
if (DotNetCoreUtil.IsRunningOnDotNetCore)
|
||||
{
|
||||
options.Client = "httpclientnetcore";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Jackett.Common.Models.Config;
|
||||
using Jackett.Common.Services.Interfaces;
|
||||
using Jackett.Common.Utils;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using NLog;
|
||||
|
@ -121,10 +122,8 @@ namespace Jackett.Server.Services
|
|||
logger.Error(e, "Error while reading the issue file");
|
||||
}
|
||||
|
||||
bool runningOnDotNetCore = RuntimeInformation.FrameworkDescription.IndexOf("Core", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
|
||||
Type monotype = Type.GetType("Mono.Runtime");
|
||||
if (monotype != null && !runningOnDotNetCore)
|
||||
if (monotype != null && !DotNetCoreUtil.IsRunningOnDotNetCore)
|
||||
{
|
||||
MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
var monoVersion = "unknown";
|
||||
|
|
Loading…
Reference in New Issue