First pass at the auto updater, inital tests on windows seem good!
This commit is contained in:
tidusjar 2017-08-06 22:40:08 +01:00
parent d59f940b10
commit 1647717915
4 changed files with 36 additions and 16 deletions

View file

@ -21,7 +21,7 @@ namespace Ombi.Schedule
{ {
RecurringJob.AddOrUpdate(() => Cacher.CacheContent(), Cron.Hourly); RecurringJob.AddOrUpdate(() => Cacher.CacheContent(), Cron.Hourly);
RecurringJob.AddOrUpdate(() => RadarrCacher.CacheContent(), Cron.Hourly); RecurringJob.AddOrUpdate(() => RadarrCacher.CacheContent(), Cron.Hourly);
//RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Hourly); RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Minutely);
} }
} }
} }

View file

@ -12,6 +12,7 @@ using Microsoft.Extensions.Options;
using Ombi.Api.Service; using Ombi.Api.Service;
using Ombi.Api.Service.Models; using Ombi.Api.Service.Models;
using Ombi.Helpers; using Ombi.Helpers;
using System.IO.Compression;
namespace Ombi.Schedule.Ombi namespace Ombi.Schedule.Ombi
{ {
@ -92,23 +93,41 @@ namespace Ombi.Schedule.Ombi
return; return;
} }
} }
if(download == null)
{
return;
}
// Download it // Download it
await DownloadAsync(download.Url, Path.Combine(currentLocation, "Ombi.zip")); var extension = download.Name.Split('.').Last();
var zipDir = Path.Combine(currentLocation, $"Ombi.{extension}");
await DownloadAsync(download.Url, zipDir);
var tempPath = Path.Combine(currentLocation, "TempUpdate");
// Extract it
using (var files = ZipFile.OpenRead(zipDir))
{
foreach (var entry in files.Entries)
{
// Temp Path
Directory.CreateDirectory(tempPath);
entry.ExtractToFile(Path.Combine(tempPath, entry.FullName));
}
}
// There must be an update // There must be an update
//var start = new ProcessStartInfo var start = new ProcessStartInfo
//{ {
// UseShellExecute = false, UseShellExecute = false,
// CreateNoWindow = true, CreateNoWindow = true,
// FileName = "Ombi.Updater.exe", FileName = "Ombi.Updater",
// Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + " " +extension ,
//}; };
//using (var proc = new Process { StartInfo = start }) using (var proc = new Process { StartInfo = start })
//{ {
// proc.Start(); proc.Start();
//} }
} }
else else

View file

@ -33,8 +33,8 @@ namespace Ombi.Updater
var start = new ProcessStartInfo var start = new ProcessStartInfo
{ {
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true, FileName = Path.Combine(options.ApplicationPath,"Ombi.exe"),
FileName = Path.Combine(options.ApplicationPath,"Ombi.exe") WorkingDirectory = options.ApplicationPath
}; };
using (var proc = new Process { StartInfo = start }) using (var proc = new Process { StartInfo = start })
{ {

View file

@ -1,7 +1,8 @@
{ {
"profiles": { "profiles": {
"Ombi.Updater": { "Ombi.Updater": {
"commandName": "Project" "commandName": "Project",
"commandLineArgs": "C:\\Users\\Jamie\\Desktop\\Test\\"
} }
} }
} }