|
|
|
@ -8,6 +8,8 @@ using System.Net.Http;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Hangfire.Console;
|
|
|
|
|
using Hangfire.Server;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
using Ombi.Api.Service;
|
|
|
|
@ -28,15 +30,17 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
private ILogger<OmbiAutomaticUpdater> Logger { get; }
|
|
|
|
|
private IOmbiService OmbiService { get; }
|
|
|
|
|
|
|
|
|
|
public async Task Update()
|
|
|
|
|
public async Task Update(PerformContext c)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
c.WriteLine("Starting the updater");
|
|
|
|
|
// IF AutoUpdateEnabled =>
|
|
|
|
|
// ELSE Return;
|
|
|
|
|
var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
|
|
|
|
c.WriteLine("Path: {0}", currentLocation);
|
|
|
|
|
|
|
|
|
|
var productVersion = AssemblyHelper.GetRuntimeVersion();
|
|
|
|
|
Logger.LogInformation(LoggingEvents.Updater, "Product Version {0}", productVersion);
|
|
|
|
|
c.WriteLine("Product Version {0}", productVersion);
|
|
|
|
|
|
|
|
|
|
var productArray = productVersion.Split('-');
|
|
|
|
|
var version = productArray[0];
|
|
|
|
@ -46,15 +50,17 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
Logger.LogInformation(LoggingEvents.Updater, "Version {0}", version);
|
|
|
|
|
Logger.LogInformation(LoggingEvents.Updater, "Branch {0}", branch);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var updates = await OmbiService.GetUpdates(branch);
|
|
|
|
|
var serverVersion = updates.UpdateVersionString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logger.LogInformation(LoggingEvents.Updater, "Service Version {0}", updates.UpdateVersionString);
|
|
|
|
|
c.WriteLine("Service Version {0}", updates.UpdateVersionString);
|
|
|
|
|
|
|
|
|
|
if (!serverVersion.Equals(version, StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Let's download the correct zip
|
|
|
|
|
var desc = RuntimeInformation.OSDescription;
|
|
|
|
|
var proce = RuntimeInformation.ProcessArchitecture;
|
|
|
|
@ -161,6 +167,12 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
c.WriteLine(e);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static async Task DownloadAsync(string requestUri, string filename)
|
|
|
|
|
{
|
|
|
|
|