#1460 #865 working on the auto updater

This commit is contained in:
Jamie.Rees 2017-08-31 10:57:16 +01:00
parent ff242f2531
commit f60d133f41
11 changed files with 77 additions and 39 deletions

View file

@ -1,6 +1,10 @@
version: 3.0.{build} version: 3.0.{build}
configuration: Release configuration: Release
os: Visual Studio 2015 os: Visual Studio 2015
dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
environment: environment:
nodejs_version: "7.8.0" nodejs_version: "7.8.0"
@ -29,8 +33,6 @@ after_build:
#cache:
#- '%USERPROFILE%\.nuget\packages'
deploy: deploy:
- provider: GitHub - provider: GitHub
release: Ombi v$(appveyor_build_version) release: Ombi v$(appveyor_build_version)

View file

@ -1,15 +0,0 @@
using System;
namespace Ombi.Api.Telegram
{
public class TelegramApi
{
public TelegramApi(IApi api)
{
Api = api;
}
//https://core.telegram.org/bots/api
//https://github.com/TelegramBots/telegram.bot
private IApi Api { get; }
}
}

View file

@ -4,6 +4,10 @@
<TargetFramework>netstandard1.6</TargetFramework> <TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Telegram.Bot" Version="13.1.0" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" /> <ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</ItemGroup> </ItemGroup>

View file

@ -0,0 +1,21 @@
using System;
using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Types;
namespace Ombi.Api.Telegram
{
public class TelegramApi
{
//https://core.telegram.org/bots/api
//https://github.com/TelegramBots/telegram.bot
public async Task Send()
{
var botClient = new TelegramBotClient("422833810:AAEztVaoaSIeoXI3l9-rECKlSKJZtpFuMAU");
var me = await botClient.GetMeAsync();
await botClient.SendTextMessageAsync(new ChatId("@Ombi"), "Test");
}
}
}

View file

@ -21,7 +21,9 @@ 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.Daily); //RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Daily);
BackgroundJob.Enqueue(() => Updater.Update());
} }
} }
} }

View file

@ -93,7 +93,7 @@ namespace Ombi.Schedule.Ombi
return; return;
} }
} }
if(download == null) if (download == null)
{ {
return; return;
} }
@ -101,16 +101,34 @@ namespace Ombi.Schedule.Ombi
// Download it // Download it
var extension = download.Name.Split('.').Last(); var extension = download.Name.Split('.').Last();
var zipDir = Path.Combine(currentLocation, $"Ombi.{extension}"); var zipDir = Path.Combine(currentLocation, $"Ombi.{extension}");
try
{
await DownloadAsync(download.Url, zipDir); await DownloadAsync(download.Url, zipDir);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
var tempPath = Path.Combine(currentLocation, "TempUpdate"); var tempPath = Path.Combine(currentLocation, "TempUpdate");
if (Directory.Exists(tempPath))
{
Directory.Delete(tempPath, true);
}
// Extract it // Extract it
using (var files = ZipFile.OpenRead(zipDir)) using (var files = ZipFile.OpenRead(zipDir))
{
foreach (var entry in files.Entries)
{ {
// Temp Path // Temp Path
Directory.CreateDirectory(tempPath); Directory.CreateDirectory(tempPath);
foreach (var entry in files.Entries)
{
if (entry.FullName.Contains("/"))
{
var path = Path.GetDirectoryName(Path.Combine(tempPath, entry.FullName));
Directory.CreateDirectory(path);
}
entry.ExtractToFile(Path.Combine(tempPath, entry.FullName)); entry.ExtractToFile(Path.Combine(tempPath, entry.FullName));
} }
@ -122,7 +140,7 @@ namespace Ombi.Schedule.Ombi
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true, CreateNoWindow = true,
FileName = "Ombi.Updater", FileName = "Ombi.Updater",
Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + " " +extension , Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + " " + extension,
}; };
using (var proc = new Process { StartInfo = start }) using (var proc = new Process { StartInfo = start })
{ {

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace Ombi.Updater namespace Ombi.Updater
@ -30,10 +31,16 @@ namespace Ombi.Updater
private void StartOmbi(StartupOptions options) private void StartOmbi(StartupOptions options)
{ {
var fileName = "Ombi.exe";
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
fileName = "Ombi";
}
var start = new ProcessStartInfo var start = new ProcessStartInfo
{ {
UseShellExecute = false, UseShellExecute = false,
FileName = Path.Combine(options.ApplicationPath,"Ombi.exe"), FileName = Path.Combine(options.ApplicationPath,fileName),
WorkingDirectory = options.ApplicationPath WorkingDirectory = options.ApplicationPath
}; };
using (var proc = new Process { StartInfo = start }) using (var proc = new Process { StartInfo = start })

View file

@ -8,9 +8,9 @@ namespace Ombi.Updater
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
Console.WriteLine("======================================="); Console.WriteLine(" =======================================");
Console.WriteLine(" Starting the Ombi Updater" ); Console.WriteLine(" Starting the Ombi Updater" );
Console.WriteLine("======================================="); Console.WriteLine(" =======================================");
var options = CheckArgs(args); var options = CheckArgs(args);

View file

@ -2,7 +2,7 @@
"profiles": { "profiles": {
"Ombi.Updater": { "Ombi.Updater": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "C:\\Users\\Jamie\\Desktop\\Test\\" "commandLineArgs": "C:\\Users\\Jamie.Rees\\Source\\Repos\\PlexRequests.Net\\src\\Ombi\\bin\\Debug\\netcoreapp1.1\\"
} }
} }
} }

View file

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Ombi.Api.Telegram;
namespace Ombi.Controllers namespace Ombi.Controllers
{ {
@ -9,7 +11,7 @@ namespace Ombi.Controllers
/// Indexes this instance. /// Indexes this instance.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public IActionResult Index() public async Task<IActionResult> Index()
{ {
return View(); return View();
} }

View file

@ -3,8 +3,10 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework> <TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeIdentifiers>win10-x64;osx.10.12-x64;ubuntu.16.04-x64;debian.8-x64;centos.7-x64;</RuntimeIdentifiers> <RuntimeIdentifiers>win10-x64;osx.10.12-x64;ubuntu.16.04-x64;debian.8-x64;centos.7-x64;</RuntimeIdentifiers>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<TypeScriptToolsVersion>2.3</TypeScriptToolsVersion> <TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -69,6 +71,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" /> <ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
<ProjectReference Include="..\Ombi.Api.Telegram\Ombi.Api.Telegram.csproj" />
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" /> <ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" />
<ProjectReference Include="..\Ombi.DependencyInjection\Ombi.DependencyInjection.csproj" /> <ProjectReference Include="..\Ombi.DependencyInjection\Ombi.DependencyInjection.csproj" />
<ProjectReference Include="..\Ombi.Mapping\Ombi.Mapping.csproj" /> <ProjectReference Include="..\Ombi.Mapping\Ombi.Mapping.csproj" />
@ -78,10 +81,4 @@
<ProjectReference Include="..\Ombi.Updater\Ombi.Updater.csproj" /> <ProjectReference Include="..\Ombi.Updater\Ombi.Updater.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="ClientApp\app\settings\notifications\slack.component.js">
<DependentUpon>slack.component.ts</DependentUpon>
</None>
</ItemGroup>
</Project> </Project>