diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-03-02 14:48:25 -0500 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-03-02 14:48:25 -0500 |
| commit | 60662a0f165d1cf4c271c95f00b57fc484ab75e3 (patch) | |
| tree | 87445a0c91639db425437b7675c787139b985c39 /MediaBrowser.Common/Updates/ApplicationUpdater.cs | |
| parent | 3abf1f7ed2b54a9b15b0b5cc746cb785379f2578 (diff) | |
Server app update on launch
Diffstat (limited to 'MediaBrowser.Common/Updates/ApplicationUpdater.cs')
| -rw-r--r-- | MediaBrowser.Common/Updates/ApplicationUpdater.cs | 37 |
1 files changed, 37 insertions, 0 deletions
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 + } + + /// <summary> + /// Update the specified application using the specified archive + /// </summary> + 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 + } + } +} |
