浏览代码

Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser

Luke Pulverenti 12 年之前
父节点
当前提交
81d38ba397
共有 1 个文件被更改,包括 20 次插入12 次删除
  1. 20 12
      MediaBrowser.Installer/MainWindow.xaml.cs

+ 20 - 12
MediaBrowser.Installer/MainWindow.xaml.cs

@@ -269,22 +269,13 @@ namespace MediaBrowser.Installer
                 {
                     ExtractPackage(archive);
                     // We're done with it so delete it (this is necessary for update operations)
-                    try
-                    {
-                        File.Delete(archive);
-                    }
-                    catch (FileNotFoundException)
-                    {
-                    }
-                    catch (Exception e)
-                    {
-                        SystemClose("Error Removing Archive - " + e.GetType().FullName + "\n\n" + e.Message);
-                        return;
-                    }
+                    TryDelete(archive);
                 }
                 catch (Exception e)
                 {
                     SystemClose("Error Extracting - " + e.GetType().FullName + "\n\n" + e.Message);
+                    // Delete archive even if failed so we don't try again with this one
+                    TryDelete(archive);
                     return;
                 }
 
@@ -337,6 +328,23 @@ namespace MediaBrowser.Installer
 
         }
 
+        private bool TryDelete(string file)
+        {
+            try
+            {
+                File.Delete(file);
+            }
+            catch (FileNotFoundException)
+            {
+            }
+            catch (Exception e)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
         private void PismoInstall()
         {
             // Kick off the Pismo installer and wait for it to end