Skip to content

Commit

Permalink
Fix a bug where directory of the old version is not deleted after upd…
Browse files Browse the repository at this point in the history
…ate.
  • Loading branch information
JetStream96 committed Feb 14, 2017
1 parent d0210aa commit 7f1facb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/QSP/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
Expand Down Expand Up @@ -141,16 +140,10 @@ private static void StartLauncher()

private static void SetExceptionHandler()
{
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
HandleException((Exception)e.ExceptionObject);
};

Application.ThreadException += (sender, e) =>
{
HandleException(e.Exception);
};

Application.ThreadException += (s, e) => HandleException(e.Exception);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
}

Expand Down
8 changes: 6 additions & 2 deletions src/QSP/Updates/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Net;
using System.Xml.Linq;
using QSP.LibraryExtension.XmlSerialization;
using static QSP.Utilities.LoggerInstance;
using static QSP.Utilities.ExceptionHelpers;
using static QSP.Updates.Utilities;
Expand Down Expand Up @@ -148,8 +149,11 @@ private static void UpdateXmlAndDeleteOldVersion(string version)
{
var doc = GetVersionXDoc();
var root = doc.Root;
var backup = root.Element("current").Value;
IgnoreException(() => Directory.Delete(root.Element("backup").Value));
var backup = root.GetString("current");

var oldBackup = root.GetString("backup");
if (oldBackup != "") Directory.Delete(Path.Combine("..", oldBackup), true);

root.Element("current").Value = version;
root.Element("backup").Value = backup;
File.WriteAllText(VersionXmlPath, doc.ToString());
Expand Down

0 comments on commit 7f1facb

Please sign in to comment.