#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}
configuration: Release
os: Visual Studio 2015
dotnet_csproj:
patch: true
file: '**\*.csproj'
version: '{version}'
environment:
nodejs_version: "7.8.0"
@ -29,8 +33,6 @@ after_build:
#cache:
#- '%USERPROFILE%\.nuget\packages'
deploy:
- provider: GitHub
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>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Telegram.Bot" Version="13.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</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(() => RadarrCacher.CacheContent(), Cron.Hourly);
RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Daily);
//RecurringJob.AddOrUpdate(() => Updater.Update(), Cron.Daily);
BackgroundJob.Enqueue(() => Updater.Update());
}
}
}

View file

@ -101,16 +101,34 @@ namespace Ombi.Schedule.Ombi
// Download it
var extension = download.Name.Split('.').Last();
var zipDir = Path.Combine(currentLocation, $"Ombi.{extension}");
try
{
await DownloadAsync(download.Url, zipDir);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
var tempPath = Path.Combine(currentLocation, "TempUpdate");
if (Directory.Exists(tempPath))
{
Directory.Delete(tempPath, true);
}
// Extract it
using (var files = ZipFile.OpenRead(zipDir))
{
foreach (var entry in files.Entries)
{
// Temp Path
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));
}

View file

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

View file

@ -2,7 +2,7 @@
"profiles": {
"Ombi.Updater": {
"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
{
@ -9,7 +11,7 @@ namespace Ombi.Controllers
/// Indexes this instance.
/// </summary>
/// <returns></returns>
public IActionResult Index()
public async Task<IActionResult> Index()
{
return View();
}

View file

@ -3,8 +3,10 @@
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<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>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -69,6 +71,7 @@
<ItemGroup>
<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.DependencyInjection\Ombi.DependencyInjection.csproj" />
<ProjectReference Include="..\Ombi.Mapping\Ombi.Mapping.csproj" />
@ -78,10 +81,4 @@
<ProjectReference Include="..\Ombi.Updater\Ombi.Updater.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="ClientApp\app\settings\notifications\slack.component.js">
<DependentUpon>slack.component.ts</DependentUpon>
</None>
</ItemGroup>
</Project>