mirror of https://github.com/Jackett/Jackett
parent
eaa4126da5
commit
13baa27656
|
@ -52,7 +52,7 @@ namespace Jackett.Common.Services
|
|||
throw new Exception("Could not create settings directory. " + ex.Message);
|
||||
}
|
||||
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
if (Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -69,9 +69,7 @@ namespace Jackett.Common.Services
|
|||
{
|
||||
try
|
||||
{
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
processService.StartProcessAndLog(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath, "--MigrateSettings", true);
|
||||
processService.StartProcessAndLog(EnvironmentUtil.JackettExecutablePath(), "--MigrateSettings", true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -166,9 +164,7 @@ namespace Jackett.Common.Services
|
|||
}
|
||||
}
|
||||
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
public string ApplicationFolder() => Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
|
||||
public string ApplicationFolder() => EnvironmentUtil.JackettInstallationPath();
|
||||
|
||||
public string GetContentFolder()
|
||||
{
|
||||
|
|
|
@ -46,15 +46,6 @@ namespace Jackett.Common.Services
|
|||
variant = new Variants().GetVariant();
|
||||
}
|
||||
|
||||
private string ExePath()
|
||||
{
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
var location = new Uri(Assembly.GetEntryAssembly().GetName().EscapedCodeBase);
|
||||
// Use LocalPath instead of AbsolutePath to avoid needing to unescape Uri format.
|
||||
return new FileInfo(location.LocalPath).FullName;
|
||||
}
|
||||
|
||||
public void StartUpdateChecker() => Task.Factory.StartNew(UpdateWorkerThread);
|
||||
|
||||
public void CheckForUpdatesNow()
|
||||
|
@ -138,7 +129,7 @@ namespace Jackett.Common.Services
|
|||
{
|
||||
var tempDir = await DownloadRelease(latestRelease.Assets, isWindows, latestRelease.Name);
|
||||
// Copy updater
|
||||
var installDir = Path.GetDirectoryName(ExePath());
|
||||
var installDir = EnvironmentUtil.JackettInstallationPath();
|
||||
var updaterPath = GetUpdaterPath(tempDir);
|
||||
if (updaterPath != null)
|
||||
StartUpdate(updaterPath, installDir, isWindows, serverConfig.RuntimeSettings.NoRestart, trayIsRunning);
|
||||
|
@ -211,7 +202,7 @@ namespace Jackett.Common.Services
|
|||
public void CheckUpdaterLock()
|
||||
{
|
||||
// check .lock file to detect errors in the update process
|
||||
var lockFilePath = Path.Combine(Path.GetDirectoryName(ExePath()), ".lock");
|
||||
var lockFilePath = Path.Combine(EnvironmentUtil.JackettInstallationPath(), ".lock");
|
||||
if (File.Exists(lockFilePath))
|
||||
{
|
||||
logger.Error("An error occurred during the last update. If this error occurs again, you need to reinstall " +
|
||||
|
@ -313,7 +304,6 @@ namespace Jackett.Common.Services
|
|||
if (isWindows && windowsService.ServiceExists() && windowsService.ServiceRunning())
|
||||
appType = "WindowsService";
|
||||
|
||||
var exe = Path.GetFileName(ExePath());
|
||||
var args = string.Join(" ", Environment.GetCommandLineArgs().Skip(1).Select(a => a.Contains(" ") ? "\"" + a + "\"" : a)).Replace("\"", "\\\"");
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
|
@ -326,7 +316,7 @@ namespace Jackett.Common.Services
|
|||
if (variant == Variants.JackettVariant.Mono)
|
||||
{
|
||||
// Wrap mono
|
||||
args = exe + " " + args;
|
||||
args = Path.GetFileName(EnvironmentUtil.JackettExecutablePath()) + " " + args;
|
||||
|
||||
startInfo.Arguments = $"{Path.Combine(updaterExePath)} --Path \"{installLocation}\" --Type \"{appType}\" --Args \" {args}\"";
|
||||
startInfo.FileName = "mono";
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.ServiceProcess;
|
||||
using Jackett.Common.Services.Interfaces;
|
||||
using Jackett.Common.Utils;
|
||||
using NLog;
|
||||
|
||||
namespace Jackett.Common.Services
|
||||
|
@ -51,10 +52,7 @@ namespace Jackett.Common.Services
|
|||
}
|
||||
else
|
||||
{
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
|
||||
|
||||
var applicationFolder = EnvironmentUtil.JackettInstallationPath();
|
||||
var exePath = Path.Combine(applicationFolder, SERVICEEXE);
|
||||
if (!File.Exists(exePath) && Debugger.IsAttached)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Jackett.Common.Utils
|
||||
|
@ -14,6 +15,16 @@ namespace Jackett.Common.Utils
|
|||
return $"v{fvi.ProductVersion}";
|
||||
}
|
||||
|
||||
public static string JackettInstallationPath()
|
||||
{
|
||||
return Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location);
|
||||
}
|
||||
|
||||
public static string JackettExecutablePath()
|
||||
{
|
||||
return Assembly.GetEntryAssembly()?.Location;
|
||||
}
|
||||
|
||||
public static bool IsWindows => Environment.OSVersion.Platform == PlatformID.Win32NT;
|
||||
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ namespace Jackett.Server.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var consoleExePath = System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Replace(".dll", ".exe");
|
||||
var consoleExePath = EnvironmentUtil.JackettExecutablePath().Replace(".dll", ".exe");
|
||||
processService.StartProcessAndLog(consoleExePath, "--ReserveUrls", true);
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace Jackett.Server
|
|||
try
|
||||
{
|
||||
logger.Debug("Creating web host...");
|
||||
var applicationFolder = Path.Combine(configurationService.ApplicationFolder(), "Content");
|
||||
var applicationFolder = configurationService.GetContentFolder();
|
||||
logger.Debug($"Content root path is: {applicationFolder}");
|
||||
|
||||
CreateWebHostBuilder(args, url, applicationFolder).Build().Run();
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Reflection;
|
|||
using System.ServiceProcess;
|
||||
using Jackett.Common.Services;
|
||||
using Jackett.Common.Services.Interfaces;
|
||||
using Jackett.Common.Utils;
|
||||
using NLog;
|
||||
|
||||
namespace Jackett.Server.Services
|
||||
|
@ -49,10 +50,7 @@ namespace Jackett.Server.Services
|
|||
}
|
||||
else
|
||||
{
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
|
||||
|
||||
var applicationFolder = EnvironmentUtil.JackettInstallationPath();
|
||||
var exePath = Path.Combine(applicationFolder, SERVICEEXE);
|
||||
if (!File.Exists(exePath) && Debugger.IsAttached)
|
||||
{
|
||||
|
|
|
@ -51,11 +51,7 @@ namespace Jackett.Service
|
|||
|
||||
private void StartConsoleApplication()
|
||||
{
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
|
||||
|
||||
var exePath = Path.Combine(applicationFolder, "JackettConsole.exe");
|
||||
var exePath = Path.Combine(EnvironmentUtil.JackettInstallationPath(), "JackettConsole.exe");
|
||||
|
||||
var startInfo = new ProcessStartInfo()
|
||||
{
|
||||
|
|
|
@ -15,14 +15,13 @@ namespace Jackett.Test.Common.Definitions
|
|||
[Test]
|
||||
public void LoadAndParseAllCardigannDefinitions()
|
||||
{
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath);
|
||||
var definitionsFolder = Path.GetFullPath(Path.Combine(applicationFolder, "Definitions"));
|
||||
var applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
|
||||
var definitionsFolder = Path.Combine(applicationFolder, "Definitions");
|
||||
var deserializer = new DeserializerBuilder()
|
||||
.WithNamingConvention(CamelCaseNamingConvention.Instance)
|
||||
.Build();
|
||||
var files = new DirectoryInfo(definitionsFolder).GetFiles("*.yml");
|
||||
Assert.True(files.Length > 0);
|
||||
foreach (var file in files)
|
||||
try
|
||||
{
|
||||
|
|
|
@ -261,9 +261,7 @@ namespace Jackett.Tray
|
|||
|
||||
private void StartConsoleApplication()
|
||||
{
|
||||
var applicationFolder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
|
||||
|
||||
var exePath = Path.Combine(applicationFolder, "JackettConsole.exe");
|
||||
var exePath = Path.Combine(EnvironmentUtil.JackettInstallationPath(), "JackettConsole.exe");
|
||||
|
||||
var startInfo = new ProcessStartInfo()
|
||||
{
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace Jackett.Updater
|
|||
|
||||
private void ProcessUpdate(UpdaterConsoleOptions options)
|
||||
{
|
||||
var updateLocation = GetUpdateLocation();
|
||||
var updateLocation = EnvironmentUtil.JackettInstallationPath();
|
||||
if (!(updateLocation.EndsWith("\\") || updateLocation.EndsWith("/")))
|
||||
updateLocation += Path.DirectorySeparatorChar;
|
||||
|
||||
|
@ -608,15 +608,6 @@ namespace Jackett.Updater
|
|||
return success;
|
||||
}
|
||||
|
||||
private string GetUpdateLocation()
|
||||
{
|
||||
// Use EscapedCodeBase to avoid Uri reserved characters from causing bugs
|
||||
// https://stackoverflow.com/questions/896572
|
||||
var location = new Uri(Assembly.GetEntryAssembly().GetName().EscapedCodeBase);
|
||||
// Use LocalPath instead of AbsolutePath to avoid needing to unescape Uri format.
|
||||
return new FileInfo(location.LocalPath).DirectoryName;
|
||||
}
|
||||
|
||||
private string GetJackettConsolePath(string directoryPath)
|
||||
{
|
||||
var variants = new Variants();
|
||||
|
|
Loading…
Reference in New Issue