ApplicationUpdater.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 tempUpdater = Path.Combine(Path.GetTempPath(), UpdaterExe);
  23. var product = app == MBApplication.MBTheater ? "mbt" : "server";
  24. File.Copy(source, tempUpdater, true);
  25. // Our updater needs SS and ionic
  26. source = Path.Combine(appPaths.ProgramSystemPath, "ServiceStack.Text.dll");
  27. File.Copy(source, Path.Combine(Path.GetTempPath(), "ServiceStack.Text.dll"), true);
  28. source = Path.Combine(appPaths.ProgramSystemPath, "Ionic.Zip.dll");
  29. File.Copy(source, Path.Combine(Path.GetTempPath(), "Ionic.Zip.dll"), true);
  30. Process.Start(tempUpdater, string.Format("product={0} archive=\"{1}\" caller={2} pismo=false", product, archive, Process.GetCurrentProcess().Id));
  31. // That's it. The installer will do the work once we exit
  32. }
  33. }
  34. }