mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 11:38:32 -07:00
I think we have finished the main bulk of the auto updater #29
This commit is contained in:
parent
915459a141
commit
0601f04582
4 changed files with 47 additions and 13 deletions
|
@ -68,9 +68,7 @@ namespace PlexRequests.UI
|
||||||
|
|
||||||
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
|
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
|
||||||
{
|
{
|
||||||
container.Register<IUserMapper, UserMapper>();
|
|
||||||
container.Register<ICustomUserMapper, UserMapper>();
|
|
||||||
container.Register<ISqliteConfiguration, DbConfiguration>(new DbConfiguration(new SqliteFactory()));
|
|
||||||
container.Register<ICacheProvider, MemoryCacheProvider>().AsSingleton();
|
container.Register<ICacheProvider, MemoryCacheProvider>().AsSingleton();
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
@ -88,7 +86,6 @@ namespace PlexRequests.UI
|
||||||
|
|
||||||
// Repo's
|
// Repo's
|
||||||
container.Register<IRepository<LogEntity>, GenericRepository<LogEntity>>();
|
container.Register<IRepository<LogEntity>, GenericRepository<LogEntity>>();
|
||||||
container.Register<IRepository<UsersModel>, UserRepository<UsersModel>>();
|
|
||||||
container.Register<IRepository<ScheduledJobs>, GenericRepository<ScheduledJobs>>();
|
container.Register<IRepository<ScheduledJobs>, GenericRepository<ScheduledJobs>>();
|
||||||
container.Register<IRequestService, JsonRequestService>();
|
container.Register<IRequestService, JsonRequestService>();
|
||||||
container.Register<ISettingsRepository, SettingsJsonRepository>();
|
container.Register<ISettingsRepository, SettingsJsonRepository>();
|
||||||
|
@ -121,9 +118,16 @@ namespace PlexRequests.UI
|
||||||
var loc = ServiceLocator.Instance;
|
var loc = ServiceLocator.Instance;
|
||||||
loc.SetContainer(container);
|
loc.SetContainer(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
|
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
|
||||||
{
|
{
|
||||||
|
container.Register<ISqliteConfiguration, DbConfiguration>(new DbConfiguration(new SqliteFactory()));
|
||||||
|
container.Register<IRepository<UsersModel>, UserRepository<UsersModel>>();
|
||||||
|
container.Register<IUserMapper, UserMapper>();
|
||||||
|
container.Register<ICustomUserMapper, UserMapper>();
|
||||||
|
|
||||||
|
|
||||||
CookieBasedSessions.Enable(pipelines, CryptographyConfiguration.Default);
|
CookieBasedSessions.Enable(pipelines, CryptographyConfiguration.Default);
|
||||||
|
|
||||||
StaticConfiguration.DisableErrorTraces = false;
|
StaticConfiguration.DisableErrorTraces = false;
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Web.Extensions" />
|
<Reference Include="System.Web.Extensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="CommandLine, Version=2.0.275.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32">
|
<Reference Include="CommandLine, Version=2.0.275.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32">
|
||||||
<HintPath>..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll</HintPath>
|
<HintPath>..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll</HintPath>
|
||||||
|
|
|
@ -39,6 +39,9 @@ using PlexRequests.Helpers;
|
||||||
using PlexRequests.Store;
|
using PlexRequests.Store;
|
||||||
using PlexRequests.Store.Repository;
|
using PlexRequests.Store.Repository;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
|
|
||||||
|
@ -62,10 +65,10 @@ namespace PlexRequests.UI
|
||||||
e => -1);
|
e => -1);
|
||||||
|
|
||||||
var updated = result.MapResult(x => x.Updated, e => UpdateValue.None);
|
var updated = result.MapResult(x => x.Updated, e => UpdateValue.None);
|
||||||
//TODO
|
CheckUpdate(updated);
|
||||||
|
|
||||||
PrintToConsole("Starting Up! Please wait, this can usually take a few seconds.", ConsoleColor.Yellow);
|
PrintToConsole("Starting Up! Please wait, this can usually take a few seconds.", ConsoleColor.Yellow);
|
||||||
|
|
||||||
Log.Trace("Getting product version");
|
Log.Trace("Getting product version");
|
||||||
WriteOutVersion();
|
WriteOutVersion();
|
||||||
|
|
||||||
|
@ -163,11 +166,37 @@ namespace PlexRequests.UI
|
||||||
{
|
{
|
||||||
if (val == UpdateValue.Failed)
|
if (val == UpdateValue.Failed)
|
||||||
{
|
{
|
||||||
|
PrintToConsole("Update Failed", ConsoleColor.Red);
|
||||||
}
|
}
|
||||||
if (val == UpdateValue.Updated)
|
if (val == UpdateValue.Updated)
|
||||||
{
|
{
|
||||||
// TODO Change the name of PlexRequests.Updater.exe_Updated and delete the old version
|
PrintToConsole("Finishing Update", ConsoleColor.Yellow);
|
||||||
|
var applicationPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath));
|
||||||
|
var files = Directory.GetFiles(applicationPath, "PlexRequests.*", SearchOption.TopDirectoryOnly);
|
||||||
|
var oldUpdater = files.FirstOrDefault(x => x == $"{applicationPath}\\PlexRequests.Updater.exe");
|
||||||
|
var newUpdater = files.FirstOrDefault(x => x == $"{applicationPath}\\PlexRequests.Updater.exe_Updated");
|
||||||
|
|
||||||
|
if (oldUpdater == null || newUpdater == null)
|
||||||
|
{
|
||||||
|
PrintToConsole("Looks like there was nothing to update.", ConsoleColor.Yellow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Copy(oldUpdater, "PlexRequests.Updater.exe_Old", true);
|
||||||
|
File.Delete(oldUpdater);
|
||||||
|
File.Copy(newUpdater, "PlexRequests.Updater.exe", true);
|
||||||
|
File.Delete(newUpdater);
|
||||||
|
|
||||||
|
File.Delete("PlexRequests.Updater.exe_Old"); // Cleanup
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintToConsole("Finished Update!", ConsoleColor.Yellow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
#endregion
|
#endregion
|
||||||
namespace PlexRequests.UI.Start
|
namespace PlexRequests.UI.Start
|
||||||
{
|
{
|
||||||
public enum UpdateValue
|
public enum UpdateValue : int
|
||||||
{
|
{
|
||||||
None,
|
None = 0,
|
||||||
Updated,
|
Updated = 1,
|
||||||
Failed
|
Failed = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue