The Free Software Media System - Server Backend & API
Attempt to fix in-place updates #52
Eric Reed2f64303dcdc3
diff --git a/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs b/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.csindex 7ab5745474..9dc0eb85c8 100644--- a/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs+++ b/MediaBrowser.Common.Implementations/Updates/ApplicationUpdater.cs@@ -21,10 +21,15 @@ namespace MediaBrowser.Common.Implementations.Updates// Use our installer passing it the specific archive// We need to copy to a temp directory and execute it therevar source = Path.Combine(appPaths.ProgramSystemPath, UpdaterExe);- var target = Path.Combine(Path.GetTempPath(), UpdaterExe);+ var tempUpdater = Path.Combine(Path.GetTempPath(), UpdaterExe);var product = app == MBApplication.MBTheater ? "mbt" : "server";- File.Copy(source, target, true);- Process.Start(target, string.Format("product={0} archive=\"{1}\" caller={2} pismo=false", product, archive, Process.GetCurrentProcess().Id));+ File.Copy(source, tempUpdater, true);+ // 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));// That's it. The installer will do the work once we exit}diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.csindex 2a905293c9..0cf8c2425c 100644--- a/MediaBrowser.Installer/MainWindow.xaml.cs+++ b/MediaBrowser.Installer/MainWindow.xaml.cs@@ -38,9 +38,16 @@ namespace MediaBrowser.Installerpublic MainWindow(){- GetArgs();- InitializeComponent();- DoInstall(Archive);+ try+ {+ GetArgs();+ InitializeComponent();+ DoInstall(Archive);+ }+ catch (Exception e)+ {+ MessageBox.Show("Error: " + e.Message + " \n\n" + e.StackTrace);+ }}private void btnCancel_Click(object sender, RoutedEventArgs e)@@ -90,7 +97,6 @@ namespace MediaBrowser.Installerargs[nameValue[0]] = nameValue[1];}}-Archive = args.GetValueOrDefault("archive", null);if (args.GetValueOrDefault("pismo","true") == "false") InstallPismo = false;@@ -113,6 +119,8 @@ namespace MediaBrowser.Installer}}+ //MessageBox.Show(string.Format("Called with args: product: {0} archive: {1} caller: {2}", product, Archive, callerId));+switch (product.ToLower()){case "mbt":@@ -143,8 +151,8 @@ namespace MediaBrowser.InstallerlblStatus.Text = string.Format("Installing {0}...", FriendlyName);// Determine Package version- var version = await GetPackageVersion();- ActualVersion = version.version;+ var version = archive == null ? await GetPackageVersion() : null;+ ActualVersion = version != null ? version.version : new Version(3,0);// Now try and shut down the server if that is what we are installing and it is runningvar procs = Process.GetProcessesByName("mediabrowser.serverapplication");@@ -168,9 +176,9 @@ namespace MediaBrowser.Installer}catch (WebException e){- if (e.GetStatus() == HttpStatusCode.NotFound || e.Message.StartsWith("Unable to connect",StringComparison.OrdinalIgnoreCase)) return; // just wasn't running+ if (e.Status == WebExceptionStatus.Timeout || e.Message.StartsWith("Unable to connect",StringComparison.OrdinalIgnoreCase)) return; // just wasn't running- MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + e.GetStatus() + "\n\n" + e.Message);+ MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + e.Status + "\n\n" + e.Message);}}}