From 60662a0f165d1cf4c271c95f00b57fc484ab75e3 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sat, 2 Mar 2013 14:48:25 -0500 Subject: Server app update on launch --- MediaBrowser.Common/Updates/ApplicationUpdater.cs | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 MediaBrowser.Common/Updates/ApplicationUpdater.cs (limited to 'MediaBrowser.Common/Updates/ApplicationUpdater.cs') diff --git a/MediaBrowser.Common/Updates/ApplicationUpdater.cs b/MediaBrowser.Common/Updates/ApplicationUpdater.cs new file mode 100644 index 000000000..e157c344b --- /dev/null +++ b/MediaBrowser.Common/Updates/ApplicationUpdater.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using MediaBrowser.Common.Kernel; + +namespace MediaBrowser.Common.Updates +{ + public enum MBApplication + { + MBServer, + MBTheater + } + + /// + /// Update the specified application using the specified archive + /// + public class ApplicationUpdater + { + private const string UpdaterExe = "Mediabrowser.Installer.exe"; + 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); + var target = Path.Combine(Path.GetTempPath(), UpdaterExe); + var product = app == MBApplication.MBTheater ? "mbt" : "server"; + File.Copy(source, target, true); + Process.Start(UpdaterExe, string.Format("product={0} archive=\"{1}\" caller={2}", product, archive, Process.GetCurrentProcess().Id)); + + // That's it. The installer will do the work once we exit + } + } +} -- cgit v1.2.3