mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -07:00
All Sln changes
This commit is contained in:
parent
b5855f2644
commit
796f0fc188
615 changed files with 68 additions and 747 deletions
60
Ombi.Updater/Ombi.Updater.csproj
Normal file
60
Ombi.Updater/Ombi.Updater.csproj
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{EBE6FC1C-7B4B-47E9-AF54-0EE0604A2BE5}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Ombi.Updater</RootNamespace>
|
||||
<AssemblyName>Ombi.Updater</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Polly, Version=4.3.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Polly-Signed.4.3.0\lib\net45\Polly.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.IO.Compression.FileSystem" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Updater.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj">
|
||||
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
|
||||
<Name>Ombi.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj">
|
||||
<Project>{1252336D-42A3-482A-804C-836E60173DFA}</Project>
|
||||
<Name>Ombi.Helpers</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
21
Ombi.Updater/Program.cs
Normal file
21
Ombi.Updater/Program.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
|
||||
namespace Ombi.Updater
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
Console.WriteLine ("Starting PlexRequests .Net updater");
|
||||
var s = new Updater();
|
||||
if (args.Length >= 2)
|
||||
{
|
||||
s.Start(args[0], args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Start(args[0], string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
27
Ombi.Updater/Properties/AssemblyInfo.cs
Normal file
27
Ombi.Updater/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("Ombi.Updater")]
|
||||
[assembly: AssemblyDescription ("")]
|
||||
[assembly: AssemblyConfiguration ("")]
|
||||
[assembly: AssemblyCompany ("")]
|
||||
[assembly: AssemblyProduct("Ombi.Updater")]
|
||||
[assembly: AssemblyCopyright ("TidusJar")]
|
||||
[assembly: AssemblyTrademark ("")]
|
||||
[assembly: AssemblyCulture ("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion ("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
212
Ombi.Updater/Updater.cs
Normal file
212
Ombi.Updater/Updater.cs
Normal file
|
@ -0,0 +1,212 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: Updater.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Ombi.Updater
|
||||
{
|
||||
public class Updater
|
||||
{
|
||||
private string BackupPath { get; set; }
|
||||
private bool Error { get; set; }
|
||||
private string TempPath { get; set; }
|
||||
|
||||
public void RestoreBackup()
|
||||
{
|
||||
Console.WriteLine("Update failed, restoring backup");
|
||||
using (var archive = ZipFile.OpenRead(BackupPath))
|
||||
{
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
var fullPath = Path.Combine(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath)), entry.FullName);
|
||||
|
||||
if (string.IsNullOrEmpty(entry.Name))
|
||||
{
|
||||
Directory.CreateDirectory(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry.Name.Contains("PlexRequests.Updater"))
|
||||
{
|
||||
entry.ExtractToFile(fullPath + "_Updated", true);
|
||||
continue;
|
||||
}
|
||||
|
||||
entry.ExtractToFile(fullPath, true);
|
||||
Console.WriteLine("Update failed, restoring backup");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Start(string downloadPath, string launchOptions)
|
||||
{
|
||||
try
|
||||
{
|
||||
BackupCurrentVersion();
|
||||
var dir = CreateTempPath();
|
||||
TempPath = Path.Combine(dir.FullName, "PlexRequestsUpdate.zip");
|
||||
|
||||
CheckAndDelete(TempPath);
|
||||
Console.WriteLine("Downloading new version");
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
client.DownloadProgressChanged += (s, e) =>
|
||||
{
|
||||
Console.WriteLine($"{e.ProgressPercentage}%");
|
||||
};
|
||||
client.DownloadFile(downloadPath, TempPath);
|
||||
}
|
||||
Console.WriteLine("Downloaded!");
|
||||
|
||||
|
||||
// Replace files
|
||||
using (var archive = ZipFile.OpenRead(TempPath))
|
||||
{
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
var fullname = string.Empty;
|
||||
if (entry.FullName.Contains("Release/")) // Don't extract the release folder, we are already in there
|
||||
{
|
||||
fullname = entry.FullName.Replace("Release/", string.Empty);
|
||||
}
|
||||
|
||||
var fullPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), fullname);
|
||||
|
||||
if (string.IsNullOrEmpty(entry.Name))
|
||||
{
|
||||
Directory.CreateDirectory(fullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry.Name.Contains("PlexRequests.Updater"))
|
||||
{
|
||||
entry.ExtractToFile(fullPath + "_Updated", true);
|
||||
continue;
|
||||
}
|
||||
|
||||
entry.ExtractToFile(fullPath, true);
|
||||
Console.WriteLine("Restored {0}", entry.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine("Oops... Looks like we cannot update!");
|
||||
Console.ReadLine();
|
||||
Error = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(TempPath);
|
||||
if (Error)
|
||||
{
|
||||
RestoreBackup();
|
||||
}
|
||||
|
||||
FinishUpdate(launchOptions);
|
||||
}
|
||||
}
|
||||
|
||||
private void BackupCurrentVersion()
|
||||
{
|
||||
Console.WriteLine("Backing up the current version");
|
||||
try
|
||||
{
|
||||
var applicationPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Updater)).Location ?? string.Empty) ?? string.Empty;
|
||||
|
||||
var dir = Directory.CreateDirectory(Path.Combine(applicationPath, "BackupSystem"));
|
||||
|
||||
var allfiles = Directory.GetFiles(applicationPath, "*.*", SearchOption.AllDirectories);
|
||||
BackupPath = Path.Combine(dir.FullName, "PlexRequestsBackup.zip");
|
||||
|
||||
CheckAndDelete(BackupPath);
|
||||
using (var fileStream = new FileStream(BackupPath, FileMode.CreateNew))
|
||||
using (var archive = new ZipArchive(fileStream, ZipArchiveMode.Create, true))
|
||||
{
|
||||
foreach (var file in allfiles)
|
||||
{
|
||||
if (file.Contains("BackupSystem"))
|
||||
continue;
|
||||
var info = Path.GetFileName(file);
|
||||
archive.CreateEntryFromFile(file, info);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("All backed up!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine();
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckAndDelete(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
private DirectoryInfo CreateTempPath()
|
||||
{
|
||||
try
|
||||
{
|
||||
var location = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Updater)).Location ?? string.Empty);
|
||||
var path = Path.Combine(location, "UpdateTemp");
|
||||
return Directory.CreateDirectory(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine();
|
||||
Environment.Exit(1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void FinishUpdate(string launchOptions)
|
||||
{
|
||||
var args = Error ? "-u 2" : "-u 1";
|
||||
var startInfo = new ProcessStartInfo($"{launchOptions}PlexRequests.exe") { Arguments = args, UseShellExecute = true };
|
||||
|
||||
Process.Start(startInfo);
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
11
Ombi.Updater/app.config
Normal file
11
Ombi.Updater/app.config
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
4
Ombi.Updater/packages.config
Normal file
4
Ombi.Updater/packages.config
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Polly-Signed" version="4.3.0" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Add table
Add a link
Reference in a new issue