Skip to content

Commit

Permalink
Delete a file that is in the wrong place and handle our updating of D…
Browse files Browse the repository at this point in the history
…LLs better
  • Loading branch information
richardbenson committed Sep 15, 2011
1 parent 65dae3c commit 2c67cc7
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions Source/YAMS-Updater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Runtime.InteropServices;
using YAMS;
using System.Security.Principal;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace YAMS_Updater
{
Expand Down Expand Up @@ -131,6 +133,9 @@ public static void StartService()
}
else
{
//Special case for a file that shouldn't be where it is
if (File.Exists(RootFolder + @"\SharpUPnP.dll")) File.Delete(RootFolder + @"\SharpUPnP.dll");

//Apply any updates to core files, these should cope with any other updates
if (File.Exists(RootFolder + @"\YAMS-Library.dll.UPDATE"))
{
Expand All @@ -151,29 +156,18 @@ public static void StartService()
File.Move(RootFolder + @"\YAMS-Service.exe.config.UPDATE", RootFolder + @"\YAMS-Service.exe.config");
}

if (File.Exists(RootFolder + @"\ExceptionManager.dll.UPDATE"))
{
if (File.Exists(RootFolder + @"\ExceptionManager.dll.OLD")) File.Delete(RootFolder + @"\ExceptionManager.dll.OLD");
File.Move(RootFolder + @"\ExceptionManager.dll", RootFolder + @"\ExceptionManager.dll.OLD");
File.Move(RootFolder + @"\ExceptionManager.dll.UPDATE", RootFolder + @"\ExceptionManager.dll");
}
if (File.Exists(RootFolder + @"\HttpServer.dll.UPDATE"))
{
if (File.Exists(RootFolder + @"\HttpServer.dll.OLD")) File.Delete(RootFolder + @"\HttpServer.dll.OLD");
File.Move(RootFolder + @"\HttpServer.dll", RootFolder + @"\HttpServer.dll.OLD");
File.Move(RootFolder + @"\HttpServer.dll.UPDATE", RootFolder + @"\HttpServer.dll");
}
if (File.Exists(RootFolder + @"\ICSharpCode.SharpZipLib.dll.UPDATE"))
{
if (File.Exists(RootFolder + @"\ICSharpCode.SharpZipLib.dll.OLD")) File.Delete(RootFolder + @"\ICSharpCode.SharpZipLib.dll.OLD");
File.Move(RootFolder + @"\ICSharpCode.SharpZipLib.dll", RootFolder + @"\ICSharpCode.SharpZipLib.dll.OLD");
File.Move(RootFolder + @"\ICSharpCode.SharpZipLib.dll.UPDATE", RootFolder + @"\ICSharpCode.SharpZipLib.dll");
}
if (File.Exists(RootFolder + @"\Newtonsoft.Json.dll.UPDATE"))
string json = File.ReadAllText(RootFolder + @"\lib\versions.json");
//Dictionary<string, string> dicVers = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
JObject jVers = JObject.Parse(json);

foreach (JProperty j in jVers["libs"])
{
if (File.Exists(RootFolder + @"\Newtonsoft.Json.dll.OLD")) File.Delete(RootFolder + @"\Newtonsoft.Json.dll.OLD");
File.Move(RootFolder + @"\Newtonsoft.Json.dll", RootFolder + @"\Newtonsoft.Json.dll.OLD");
File.Move(RootFolder + @"\Newtonsoft.Json.dll.UPDATE", RootFolder + @"\Newtonsoft.Json.dll");
if (File.Exists(RootFolder + @"\lib\" + j.Name + ".UPDATE"))
{
if (File.Exists(RootFolder + @"\lib\" + j.Name + ".OLD")) File.Delete(RootFolder + @"\lib\" + j.Name + ".OLD");
if (File.Exists(RootFolder + @"\lib\" + j.Name)) File.Delete(RootFolder + @"\lib\" + j.Name);
File.Move(RootFolder + @"\lib\" + j.Name + ".UPDATE", RootFolder + @"\lib\" + j.Name);
}
}

//Restart the service
Expand Down

0 comments on commit 2c67cc7

Please sign in to comment.