From 85303626f0518f7c1d258b4e238572b78c9aef8f Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Fri, 1 Sep 2017 08:52:40 +0100 Subject: [PATCH] #1460 The assembly versioning seems to work correctly now --- src/Ombi.DependencyInjection/IocExtensions.cs | 1 + src/Ombi.Helpers/AssemblyHelper.cs | 4 +-- .../Jobs/Ombi/OmbiAutomaticUpdater.cs | 30 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index 495afd347..2dfe02c1d 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -36,6 +36,7 @@ using Ombi.Api.Service; using Ombi.Api.Slack; using Ombi.Core.Rule.Interfaces; using Ombi.Core.Senders; +using Ombi.Schedule.Jobs.Ombi; using Ombi.Schedule.Jobs.Plex; using Ombi.Schedule.Ombi; using Ombi.Store.Repository.Requests; diff --git a/src/Ombi.Helpers/AssemblyHelper.cs b/src/Ombi.Helpers/AssemblyHelper.cs index e7aba9b82..4e8fb8e66 100644 --- a/src/Ombi.Helpers/AssemblyHelper.cs +++ b/src/Ombi.Helpers/AssemblyHelper.cs @@ -9,7 +9,7 @@ namespace Ombi.Helpers Assembly.GetEntryAssembly().GetType() .GetTypeInfo() .Assembly - .GetCustomAttribute() - .Product; + .GetCustomAttribute() + .InformationalVersion; } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs index 2bb9af10d..c418911a1 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs @@ -2,32 +2,31 @@ using System.Diagnostics; using System.Globalization; using System.IO; +using System.IO.Compression; using System.Linq; using System.Net.Http; using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; + using Ombi.Api.Service; using Ombi.Api.Service.Models; using Ombi.Helpers; -using System.IO.Compression; +using Ombi.Schedule.Ombi; -namespace Ombi.Schedule.Ombi +namespace Ombi.Schedule.Jobs.Ombi { public class OmbiAutomaticUpdater : IOmbiAutomaticUpdater { - public OmbiAutomaticUpdater(ILogger log, IOmbiService service, IOptions settings) + public OmbiAutomaticUpdater(ILogger log, IOmbiService service) { Logger = log; OmbiService = service; - Settings = settings.Value; } private ILogger Logger { get; } private IOmbiService OmbiService { get; } - private ApplicationSettings Settings { get; } public async Task Update() { @@ -35,18 +34,17 @@ namespace Ombi.Schedule.Ombi // IF AutoUpdateEnabled => // ELSE Return; var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); - //var currentBranch = Settings.Branch; - var currentBranch = "BRANCH"; + + var productVersion = AssemblyHelper.GetRuntimeVersion(); -#if DEBUG - if (currentBranch == "{{BRANCH}}") - { - currentBranch = "DotNetCore"; - } -#endif - var updates = await OmbiService.GetUpdates(currentBranch); + var productArray = productVersion.Split('-'); + var version = productArray[0]; + var branch = productArray[1]; + + + var updates = await OmbiService.GetUpdates(branch); var serverVersion = updates.UpdateVersionString.Substring(1, 6); - if (serverVersion != AssemblyHelper.GetRuntimeVersion()) + if (!serverVersion.Equals(version, StringComparison.CurrentCultureIgnoreCase)) { // Let's download the correct zip