mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Avoid Engine for AspNetCore
This commit is contained in:
@@ -174,14 +174,7 @@ namespace Jackett.Common.Indexers
|
|||||||
//TODO: Remove this section once users have moved off DPAPI
|
//TODO: Remove this section once users have moved off DPAPI
|
||||||
private bool MigratedFromDPAPI(JToken jsonConfig)
|
private bool MigratedFromDPAPI(JToken jsonConfig)
|
||||||
{
|
{
|
||||||
var currentAssembly = Assembly.GetExecutingAssembly();
|
if (EnvironmentUtil.IsRunningLegacyOwin)
|
||||||
bool runningLegacyOwin = new StackTrace().GetFrames()
|
|
||||||
.Select(x => x.GetMethod().ReflectedType.Assembly).Distinct()
|
|
||||||
.Where(x => x.GetReferencedAssemblies().Any(y => y.FullName == currentAssembly.FullName))
|
|
||||||
.Where(x => x.ManifestModule.Name == "Jackett.dll" || x.ManifestModule.Name == "JackettConsole.exe")
|
|
||||||
.Count() == 2;
|
|
||||||
|
|
||||||
if (runningLegacyOwin)
|
|
||||||
{
|
{
|
||||||
//Still running legacy Owin and using the DPAPI, we don't want to migrate
|
//Still running legacy Owin and using the DPAPI, we don't want to migrate
|
||||||
logger.Debug(ID + " - Running Owin, no need to migrate from DPAPI");
|
logger.Debug(ID + " - Running Owin, no need to migrate from DPAPI");
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using CommandLine;
|
using CommandLine;
|
||||||
|
using Jackett.Common.Utils;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Jackett.Common.Models.Config
|
namespace Jackett.Common.Models.Config
|
||||||
@@ -83,7 +84,16 @@ namespace Jackett.Common.Models.Config
|
|||||||
if (options.ListenPublic && options.ListenPrivate)
|
if (options.ListenPublic && options.ListenPrivate)
|
||||||
{
|
{
|
||||||
Console.WriteLine("You can only use listen private OR listen publicly.");
|
Console.WriteLine("You can only use listen private OR listen publicly.");
|
||||||
Engine.Exit(1);
|
|
||||||
|
//TODO: Remove once off Owin
|
||||||
|
if (EnvironmentUtil.IsRunningLegacyOwin)
|
||||||
|
{
|
||||||
|
Engine.Exit(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSL Fix
|
// SSL Fix
|
||||||
|
@@ -83,7 +83,11 @@ namespace Jackett.Common.Plumbing
|
|||||||
|
|
||||||
private void RegisterWebClient<WebClientType>(ContainerBuilder builder)
|
private void RegisterWebClient<WebClientType>(ContainerBuilder builder)
|
||||||
{
|
{
|
||||||
Engine.WebClientType = typeof(WebClientType);
|
//TODO: Remove once off Owin
|
||||||
|
if (EnvironmentUtil.IsRunningLegacyOwin)
|
||||||
|
{
|
||||||
|
Engine.WebClientType = typeof(WebClientType);
|
||||||
|
}
|
||||||
builder.RegisterType<WebClientType>().As<WebClient>();
|
builder.RegisterType<WebClientType>().As<WebClient>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,8 +12,10 @@ using System.Threading.Tasks;
|
|||||||
using ICSharpCode.SharpZipLib.GZip;
|
using ICSharpCode.SharpZipLib.GZip;
|
||||||
using ICSharpCode.SharpZipLib.Tar;
|
using ICSharpCode.SharpZipLib.Tar;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
using Jackett.Common.Models.Config;
|
||||||
using Jackett.Common.Models.GitHub;
|
using Jackett.Common.Models.GitHub;
|
||||||
using Jackett.Common.Services.Interfaces;
|
using Jackett.Common.Services.Interfaces;
|
||||||
|
using Jackett.Common.Utils;
|
||||||
using Jackett.Common.Utils.Clients;
|
using Jackett.Common.Utils.Clients;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using NLog;
|
||||||
@@ -28,14 +30,16 @@ namespace Jackett.Common.Services
|
|||||||
IConfigurationService configService;
|
IConfigurationService configService;
|
||||||
ManualResetEvent locker = new ManualResetEvent(false);
|
ManualResetEvent locker = new ManualResetEvent(false);
|
||||||
ITrayLockService lockService;
|
ITrayLockService lockService;
|
||||||
|
private ServerConfig serverConfig;
|
||||||
bool forceupdatecheck = false;
|
bool forceupdatecheck = false;
|
||||||
|
|
||||||
public UpdateService(Logger l, WebClient c, IConfigurationService cfg, ITrayLockService ls)
|
public UpdateService(Logger l, WebClient c, IConfigurationService cfg, ITrayLockService ls, ServerConfig sc)
|
||||||
{
|
{
|
||||||
logger = l;
|
logger = l;
|
||||||
client = c;
|
client = c;
|
||||||
configService = cfg;
|
configService = cfg;
|
||||||
lockService = ls;
|
lockService = ls;
|
||||||
|
serverConfig = sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ExePath()
|
private string ExePath()
|
||||||
@@ -74,13 +78,12 @@ namespace Jackett.Common.Services
|
|||||||
|
|
||||||
private async Task CheckForUpdates()
|
private async Task CheckForUpdates()
|
||||||
{
|
{
|
||||||
var config = Engine.ServerConfig;
|
if (serverConfig.RuntimeSettings.NoUpdates)
|
||||||
if (config.RuntimeSettings.NoUpdates)
|
|
||||||
{
|
{
|
||||||
logger.Info($"Updates are disabled via --NoUpdates.");
|
logger.Info($"Updates are disabled via --NoUpdates.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (config.UpdateDisabled && !forceupdatecheck)
|
if (serverConfig.UpdateDisabled && !forceupdatecheck)
|
||||||
{
|
{
|
||||||
logger.Info($"Skipping update check as it is disabled.");
|
logger.Info($"Skipping update check as it is disabled.");
|
||||||
return;
|
return;
|
||||||
@@ -112,7 +115,7 @@ namespace Jackett.Common.Services
|
|||||||
|
|
||||||
var releases = JsonConvert.DeserializeObject<List<Release>>(response.Content);
|
var releases = JsonConvert.DeserializeObject<List<Release>>(response.Content);
|
||||||
|
|
||||||
if (!config.UpdatePrerelease)
|
if (!serverConfig.UpdatePrerelease)
|
||||||
{
|
{
|
||||||
releases = releases.Where(r => !r.Prerelease).ToList();
|
releases = releases.Where(r => !r.Prerelease).ToList();
|
||||||
}
|
}
|
||||||
@@ -132,7 +135,7 @@ namespace Jackett.Common.Services
|
|||||||
var installDir = Path.GetDirectoryName(ExePath());
|
var installDir = Path.GetDirectoryName(ExePath());
|
||||||
var updaterPath = Path.Combine(tempDir, "Jackett", "JackettUpdater.exe");
|
var updaterPath = Path.Combine(tempDir, "Jackett", "JackettUpdater.exe");
|
||||||
if (updaterPath != null)
|
if (updaterPath != null)
|
||||||
StartUpdate(updaterPath, installDir, isWindows, config.RuntimeSettings.NoRestart);
|
StartUpdate(updaterPath, installDir, isWindows, serverConfig.RuntimeSettings.NoRestart);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -304,7 +307,15 @@ namespace Jackett.Common.Services
|
|||||||
{
|
{
|
||||||
logger.Info("Exiting Jackett..");
|
logger.Info("Exiting Jackett..");
|
||||||
lockService.Signal();
|
lockService.Signal();
|
||||||
Engine.Exit(0);
|
//TODO: Remove once off Owin
|
||||||
|
if (EnvironmentUtil.IsRunningLegacyOwin)
|
||||||
|
{
|
||||||
|
Engine.Exit(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Jackett.Common.Utils
|
namespace Jackett.Common.Utils
|
||||||
@@ -22,6 +24,33 @@ namespace Jackett.Common.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsRunningLegacyOwin
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
bool runningOwin;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var currentAssembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
bool aspNetCorePresent = new StackTrace().GetFrames()
|
||||||
|
.Select(x => x.GetMethod().ReflectedType.Assembly).Distinct()
|
||||||
|
.Where(x => x.GetReferencedAssemblies().Any(y => y.FullName == currentAssembly.FullName))
|
||||||
|
.Where(x => x.ManifestModule.Name == "JackettConsole.exe").Select(x => x.CustomAttributes)
|
||||||
|
.FirstOrDefault()
|
||||||
|
.Where(x => x.AttributeType.Assembly.FullName.StartsWith("Microsoft.AspNetCore", StringComparison.OrdinalIgnoreCase))
|
||||||
|
.Any();
|
||||||
|
|
||||||
|
runningOwin = !aspNetCorePresent;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
runningOwin = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return runningOwin;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user