core: fix version number to match github release tag. resolves #10249 (#10413)

This commit is contained in:
Diego Heras 2020-12-07 00:14:23 +01:00 committed by GitHub
parent 2b8bc648a0
commit 38f09900ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 26 deletions

View File

@ -104,7 +104,7 @@ namespace Jackett.Common.Indexers
AddCategoryMapping(53, TorznabCatType.ConsolePS4, "Games/PS4"); AddCategoryMapping(53, TorznabCatType.ConsolePS4, "Games/PS4");
AddCategoryMapping(54, TorznabCatType.MoviesHD, "Movies/x265/1080"); 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) public override void LoadValuesFromJson(JToken jsonConfig, bool useProtectionService = false)

View File

@ -224,7 +224,7 @@ namespace Jackett.Common.Services
public string GetSonarrConfigFile() => Path.Combine(GetAppDataFolder(), "sonarr_api.json"); public string GetSonarrConfigFile() => Path.Combine(GetAppDataFolder(), "sonarr_api.json");
public string GetVersion() => EnvironmentUtil.JackettVersion; public string GetVersion() => EnvironmentUtil.JackettVersion();
public ServerConfig BuildServerConfig(RuntimeSettings runtimeSettings) public ServerConfig BuildServerConfig(RuntimeSettings runtimeSettings)
{ {

View File

@ -97,7 +97,7 @@ namespace Jackett.Common.Services
logger.Info("Skipping checking for new releases as the debugger is attached."); logger.Info("Skipping checking for new releases as the debugger is attached.");
return; return;
} }
var currentVersion = $"v{GetCurrentVersion()}"; var currentVersion = EnvironmentUtil.JackettVersion();
if (currentVersion == "v0.0.0") if (currentVersion == "v0.0.0")
{ {
logger.Info("Skipping checking for new releases because Jackett is runing in IDE."); 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")
: Path.Combine(tempDirectory, "Jackett", "JackettUpdater.exe"); : 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) private WebRequest SetDownloadHeaders(WebRequest req)
{ {
req.Headers = new Dictionary<string, string> req.Headers = new Dictionary<string, string>

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
namespace Jackett.Common.Utils namespace Jackett.Common.Utils
@ -6,7 +7,12 @@ namespace Jackett.Common.Utils
public static class EnvironmentUtil 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; public static bool IsWindows => Environment.OSVersion.Platform == PlatformID.Win32NT;

View File

@ -37,7 +37,7 @@ namespace Jackett.Server
{ {
var text = HelpText.AutoBuild(optionsResult); var text = HelpText.AutoBuild(optionsResult);
text.Copyright = " "; text.Copyright = " ";
text.Heading = "Jackett v" + EnvironmentUtil.JackettVersion; text.Heading = "Jackett " + EnvironmentUtil.JackettVersion();
Console.WriteLine(text); Console.WriteLine(text);
Environment.Exit(1); Environment.Exit(1);
}); });
@ -54,7 +54,7 @@ namespace Jackett.Server
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(Settings); LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(Settings);
var logger = LogManager.GetCurrentClassLogger(); var logger = LogManager.GetCurrentClassLogger();
logger.Info("Starting Jackett v" + EnvironmentUtil.JackettVersion); logger.Info("Starting Jackett " + EnvironmentUtil.JackettVersion());
// create PID file early // create PID file early
if (!string.IsNullOrWhiteSpace(Settings.PIDFile)) if (!string.IsNullOrWhiteSpace(Settings.PIDFile))

View File

@ -289,7 +289,7 @@ namespace Jackett.Server.Services
if (compiledData < DateTime.Now.AddMonths(-3)) if (compiledData < DateTime.Now.AddMonths(-3))
{ {
var version = configService.GetVersion(); 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); notices.Add(notice);
logger.Error(notice); logger.Error(notice);
} }

View File

@ -30,7 +30,7 @@ namespace Jackett.Service
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings); LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings);
logger = LogManager.GetCurrentClassLogger(); logger = LogManager.GetCurrentClassLogger();
logger.Info("Initiating Jackett Service v" + EnvironmentUtil.JackettVersion); logger.Info("Initiating Jackett Service " + EnvironmentUtil.JackettVersion());
processService = new ProcessService(logger); processService = new ProcessService(logger);
} }

View 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);
}
}
}

View File

@ -46,7 +46,7 @@ namespace Jackett.Tray
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings); LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings);
logger = LogManager.GetCurrentClassLogger(); logger = LogManager.GetCurrentClassLogger();
logger.Info("Starting Jackett Tray v" + EnvironmentUtil.JackettVersion); logger.Info("Starting Jackett Tray " + EnvironmentUtil.JackettVersion());
processService = new ProcessService(logger); processService = new ProcessService(logger);
windowsService = new WindowsServiceConfigService(processService, logger); windowsService = new WindowsServiceConfigService(processService, logger);
@ -73,7 +73,7 @@ namespace Jackett.Tray
StartConsoleApplication(); StartConsoleApplication();
} }
updatedVersion = updatedVersion.Equals("yes", StringComparison.OrdinalIgnoreCase) ? EnvironmentUtil.JackettVersion : updatedVersion; updatedVersion = updatedVersion.Equals("yes", StringComparison.OrdinalIgnoreCase) ? EnvironmentUtil.JackettVersion() : updatedVersion;
if (!string.IsNullOrWhiteSpace(updatedVersion)) if (!string.IsNullOrWhiteSpace(updatedVersion))
{ {

View File

@ -36,7 +36,7 @@ namespace Jackett.Updater
LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings); LogManager.Configuration = LoggingSetup.GetLoggingConfiguration(runtimeSettings);
logger = LogManager.GetCurrentClassLogger(); logger = LogManager.GetCurrentClassLogger();
logger.Info("Jackett Updater v" + GetCurrentVersion()); logger.Info("Jackett Updater " + EnvironmentUtil.JackettVersion());
logger.Info("Options \"" + string.Join("\" \"", args) + "\""); logger.Info("Options \"" + string.Join("\" \"", args) + "\"");
var variants = new Variants(); 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) private void KillPids(int[] pids)
{ {
foreach (var pid in pids) foreach (var pid in pids)
@ -775,7 +768,7 @@ namespace Jackett.Updater
{ {
var startInfo = new ProcessStartInfo() var startInfo = new ProcessStartInfo()
{ {
Arguments = $"--UpdatedVersion \" {EnvironmentUtil.JackettVersion}\"", Arguments = $"--UpdatedVersion \" {EnvironmentUtil.JackettVersion()}\"",
FileName = Path.Combine(options.Path, "JackettTray.exe"), FileName = Path.Combine(options.Path, "JackettTray.exe"),
UseShellExecute = true UseShellExecute = true
}; };