瀏覽代碼

Only try to shutdown server if actually running

Eric Reed 12 年之前
父節點
當前提交
cc574074b9
共有 2 個文件被更改,包括 14 次插入11 次删除
  1. 2 2
      MediaBrowser.Installer/MainWindow.xaml.cs
  2. 12 9
      MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs

+ 2 - 2
MediaBrowser.Installer/MainWindow.xaml.cs

@@ -114,8 +114,8 @@ namespace MediaBrowser.Installer
             var version = await GetPackageVersion();
             var version = await GetPackageVersion();
             lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
             lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
 
 
-            // Now try and shut down the server if that is what we are installing
-            if (PackageName == "MBServer")
+            // Now try and shut down the server if that is what we are installing and it is running
+            if (PackageName == "MBServer" && Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0)
             {
             {
                 using (var client = new WebClient())
                 using (var client = new WebClient())
                 {
                 {

+ 12 - 9
MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs

@@ -79,18 +79,21 @@ namespace MediaBrowser.Uninstaller.Execute
             if (Product == "Server")
             if (Product == "Server")
             {
             {
                 RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk"));
                 RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk"));
-                using (var client = new WebClient())
+                if (Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0)
                 {
                 {
-                    lblHeading.Content = "Shutting Down Server...";
-                    try
+                    using (var client = new WebClient())
                     {
                     {
-                        client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", "");
-                    }
-                    catch (WebException ex)
-                    {
-                        if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase))
+                        lblHeading.Content = "Shutting Down Server...";
+                        try
+                        {
+                            client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", "");
+                        }
+                        catch (WebException ex)
                         {
                         {
-                            MessageBox.Show("Error shutting down server.  Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message);
+                            if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase))
+                            {
+                                MessageBox.Show("Error shutting down server.  Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message);
+                            }
                         }
                         }
                     }
                     }
                 }
                 }