ApplicationUpdater.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. using MediaBrowser.Common.Configuration;
  2. using System.Diagnostics;
  3. using System.IO;
  4. namespace MediaBrowser.Common.Implementations.Updates
  5. {
  6. public enum MBApplication
  7. {
  8. MBServer,
  9. MBTheater
  10. }
  11. /// <summary>
  12. /// Update the specified application using the specified archive
  13. /// </summary>
  14. public class ApplicationUpdater
  15. {
  16. private const string UpdaterExe = "Mediabrowser.Installer.exe";
  17. public void UpdateApplication(MBApplication app, IApplicationPaths appPaths, string archive)
  18. {
  19. // Use our installer passing it the specific archive
  20. // We need to copy to a temp directory and execute it there
  21. var source = Path.Combine(appPaths.ProgramSystemPath, UpdaterExe);
  22. var target = Path.Combine(Path.GetTempPath(), UpdaterExe);
  23. var product = app == MBApplication.MBTheater ? "mbt" : "server";
  24. File.Copy(source, target, true);
  25. Process.Start(target, string.Format("product={0} archive=\"{1}\" caller={2}", product, archive, Process.GetCurrentProcess().Id));
  26. // That's it. The installer will do the work once we exit
  27. }
  28. }
  29. }