mirror of
https://github.com/Jackett/Jackett
synced 2025-03-05 11:18:14 +00:00
This commit is contained in:
parent
2b8bc648a0
commit
38f09900ca
10 changed files with 36 additions and 26 deletions
src
Jackett.Common
Jackett.Server
Jackett.Service
Jackett.Test/Common/Utils
Jackett.Tray
Jackett.Updater
|
@ -104,7 +104,7 @@ namespace Jackett.Common.Indexers
|
|||
AddCategoryMapping(53, TorznabCatType.ConsolePS4, "Games/PS4");
|
||||
AddCategoryMapping(54, TorznabCatType.MoviesHD, "Movies/x265/1080");
|
||||
|
||||
_appId = "jackett_v" + EnvironmentUtil.JackettVersion;
|
||||
_appId = "jackett_" + EnvironmentUtil.JackettVersion();
|
||||
}
|
||||
|
||||
public override void LoadValuesFromJson(JToken jsonConfig, bool useProtectionService = false)
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace Jackett.Common.Services
|
|||
|
||||
public string GetSonarrConfigFile() => Path.Combine(GetAppDataFolder(), "sonarr_api.json");
|
||||
|
||||
public string GetVersion() => EnvironmentUtil.JackettVersion;
|
||||
public string GetVersion() => EnvironmentUtil.JackettVersion();
|
||||
|
||||
public ServerConfig BuildServerConfig(RuntimeSettings runtimeSettings)
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Jackett.Common.Services
|
|||
logger.Info("Skipping checking for new releases as the debugger is attached.");
|
||||
return;
|
||||
}
|
||||
var currentVersion = $"v{GetCurrentVersion()}";
|
||||
var currentVersion = EnvironmentUtil.JackettVersion();
|
||||
if (currentVersion == "v0.0.0")
|
||||
{
|
||||
logger.Info("Skipping checking for new releases because Jackett is runing in IDE.");
|
||||
|
@ -169,13 +169,6 @@ namespace Jackett.Common.Services
|
|||
? Path.Combine(tempDirectory, "Jackett", "JackettUpdater")
|
||||
: Path.Combine(tempDirectory, "Jackett", "JackettUpdater.exe");
|
||||
|
||||
private string GetCurrentVersion()
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
return fvi.ProductVersion;
|
||||
}
|
||||
|
||||
private WebRequest SetDownloadHeaders(WebRequest req)
|
||||
{
|
||||
req.Headers = new Dictionary<string, string>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Jackett.Common.Utils
|
||||
|
@ -6,7 +7,12 @@ namespace Jackett.Common.Utils
|
|||
public static class EnvironmentUtil
|
||||
{
|
||||
|
||||
public static string JackettVersion => Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString() ?? "Unknown Version";
|
||||
public static string JackettVersion()
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
return $"v{fvi.ProductVersion}";
|
||||
}
|
||||
|
||||
public static bool IsWindows => Environment.OSVersion.Platform == PlatformID.Win32NT;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Jackett.Server
|
|||
{
|
||||
var text = HelpText.AutoBuild(optionsResult);
|
||||
text.Copyright = " ";
|
||||
text.Heading = "Jackett v" + EnvironmentUtil.JackettVersion;
|
||||
text.Heading = "Jackett " + EnvironmentUtil.JackettVersion();
|
||||
Console.WriteLine(text);
|
||||
Environment.Exit(1);
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ namespace Jackett.Server
|
|||
|
||||
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(Settings);
|
||||
var logger = LogManager.GetCurrentClassLogger();
|
||||
logger.Info("Starting Jackett v" + EnvironmentUtil.JackettVersion);
|
||||
logger.Info("Starting Jackett " + EnvironmentUtil.JackettVersion());
|
||||
|
||||
// create PID file early
|
||||
if (!string.IsNullOrWhiteSpace(Settings.PIDFile))
|
||||
|
|
|
@ -289,7 +289,7 @@ namespace Jackett.Server.Services
|
|||
if (compiledData < DateTime.Now.AddMonths(-3))
|
||||
{
|
||||
var version = configService.GetVersion();
|
||||
var notice = $"Your version of Jackett v{version} is very old. Multiple indexers are likely to fail when using an old version. Update to the latest version of Jackett.";
|
||||
var notice = $"Your version of Jackett {version} is very old. Multiple indexers are likely to fail when using an old version. Update to the latest version of Jackett.";
|
||||
notices.Add(notice);
|
||||
logger.Error(notice);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Jackett.Service
|
|||
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings);
|
||||
logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
logger.Info("Initiating Jackett Service v" + EnvironmentUtil.JackettVersion);
|
||||
logger.Info("Initiating Jackett Service " + EnvironmentUtil.JackettVersion());
|
||||
|
||||
processService = new ProcessService(logger);
|
||||
}
|
||||
|
|
18
src/Jackett.Test/Common/Utils/EnvironmentUtilTests.cs
Normal file
18
src/Jackett.Test/Common/Utils/EnvironmentUtilTests.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using Jackett.Common.Utils;
|
||||
using NUnit.Framework;
|
||||
using Assert = NUnit.Framework.Assert;
|
||||
|
||||
namespace Jackett.Test.Common.Utils
|
||||
{
|
||||
[TestFixture]
|
||||
public class EnvironmentUtilTests
|
||||
{
|
||||
[Test]
|
||||
public void TestJackettVersion()
|
||||
{
|
||||
var version = EnvironmentUtil.JackettVersion();
|
||||
Assert.True(version.StartsWith("v"));
|
||||
Assert.AreEqual(3, version.Split('.').Length);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,7 +46,7 @@ namespace Jackett.Tray
|
|||
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings);
|
||||
logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
logger.Info("Starting Jackett Tray v" + EnvironmentUtil.JackettVersion);
|
||||
logger.Info("Starting Jackett Tray " + EnvironmentUtil.JackettVersion());
|
||||
|
||||
processService = new ProcessService(logger);
|
||||
windowsService = new WindowsServiceConfigService(processService, logger);
|
||||
|
@ -73,7 +73,7 @@ namespace Jackett.Tray
|
|||
StartConsoleApplication();
|
||||
}
|
||||
|
||||
updatedVersion = updatedVersion.Equals("yes", StringComparison.OrdinalIgnoreCase) ? EnvironmentUtil.JackettVersion : updatedVersion;
|
||||
updatedVersion = updatedVersion.Equals("yes", StringComparison.OrdinalIgnoreCase) ? EnvironmentUtil.JackettVersion() : updatedVersion;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(updatedVersion))
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Jackett.Updater
|
|||
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings);
|
||||
logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
logger.Info("Jackett Updater v" + GetCurrentVersion());
|
||||
logger.Info("Jackett Updater " + EnvironmentUtil.JackettVersion());
|
||||
logger.Info("Options \"" + string.Join("\" \"", args) + "\"");
|
||||
|
||||
var variants = new Variants();
|
||||
|
@ -78,13 +78,6 @@ namespace Jackett.Updater
|
|||
}
|
||||
}
|
||||
|
||||
private string GetCurrentVersion()
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
return fvi.FileVersion;
|
||||
}
|
||||
|
||||
private void KillPids(int[] pids)
|
||||
{
|
||||
foreach (var pid in pids)
|
||||
|
@ -775,7 +768,7 @@ namespace Jackett.Updater
|
|||
{
|
||||
var startInfo = new ProcessStartInfo()
|
||||
{
|
||||
Arguments = $"--UpdatedVersion \" {EnvironmentUtil.JackettVersion}\"",
|
||||
Arguments = $"--UpdatedVersion \" {EnvironmentUtil.JackettVersion()}\"",
|
||||
FileName = Path.Combine(options.Path, "JackettTray.exe"),
|
||||
UseShellExecute = true
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue