jellyfin/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs

42 lines
1.9 KiB
C#
Raw Normal View History

2013-03-06 22:34:00 -07:00
using MediaBrowser.Common.Configuration;
2013-03-02 12:48:25 -07:00
using System.Diagnostics;
using System.IO;
2013-03-06 22:34:00 -07:00
namespace MediaBrowser.Common.Implementations.Updates
2013-03-02 12:48:25 -07:00
{
public enum MBApplication
{
MBServer,
MBTheater
}
/// <summary>
/// Update the specified application using the specified archive
/// </summary>
public class ApplicationUpdater
{
2013-04-15 14:27:24 -07:00
private const string UpdaterExe = "Mediabrowser.Updater.exe";
private const string UpdaterDll = "Mediabrowser.InstallUtil.dll";
2013-03-02 12:48:25 -07:00
public void UpdateApplication(MBApplication app, IApplicationPaths appPaths, string archive)
{
// Use our installer passing it the specific archive
// We need to copy to a temp directory and execute it there
var source = Path.Combine(appPaths.ProgramSystemPath, UpdaterExe);
2013-03-13 14:52:56 -07:00
var tempUpdater = Path.Combine(Path.GetTempPath(), UpdaterExe);
File.Copy(source, tempUpdater, true);
2013-04-15 14:27:24 -07:00
source = Path.Combine(appPaths.ProgramSystemPath, UpdaterDll);
var tempUpdaterDll = Path.Combine(Path.GetTempPath(), UpdaterDll);
File.Copy(source, tempUpdaterDll, true);
var product = app == MBApplication.MBTheater ? "mbt" : "server";
2013-03-13 14:52:56 -07:00
// Our updater needs SS and ionic
source = Path.Combine(appPaths.ProgramSystemPath, "ServiceStack.Text.dll");
File.Copy(source, Path.Combine(Path.GetTempPath(), "ServiceStack.Text.dll"), true);
source = Path.Combine(appPaths.ProgramSystemPath, "Ionic.Zip.dll");
File.Copy(source, Path.Combine(Path.GetTempPath(), "Ionic.Zip.dll"), true);
Process.Start(tempUpdater, string.Format("product={0} archive=\"{1}\" caller={2} pismo=false", product, archive, Process.GetCurrentProcess().Id));
2013-03-02 12:48:25 -07:00
// That's it. The installer will do the work once we exit
}
}
}