Merge pull request #265 from Cyberboss/GuardInterfaceDLLUpdate

Guards the interface DLL copy operation and no longer tries if the DLLs match
This commit is contained in:
Jordan Brown
2017-10-21 17:29:01 -04:00
committed by GitHub
2 changed files with 31 additions and 2 deletions
+29 -2
View File
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Timers;
@@ -438,11 +439,37 @@ namespace TGServerService
void UpdateInterfaceDll(bool overwrite)
{
if (File.Exists(InterfaceDLLName) && !overwrite)
var FileExists = File.Exists(InterfaceDLLName);
if (FileExists && !overwrite)
return;
//Copy the interface dll to the static dir
var InterfacePath = Assembly.GetAssembly(typeof(DDInteropCallHolder)).Location;
File.Copy(InterfacePath, InterfaceDLLName, overwrite);
try
{
if (FileExists)
{
var Old = File.ReadAllBytes(InterfaceDLLName);
var New = File.ReadAllBytes(InterfacePath);
if (Old.SequenceEqual(New))
return; //no need
}
File.Copy(InterfacePath, InterfaceDLLName, overwrite);
TGServerService.WriteInfo("Updated interface DLL", TGServerService.EventID.InterfaceDLLUpdated);
}
catch
{
try
{
//ok the things being stupid and hasn't released the dll yet, try ONCE more
Thread.Sleep(1000);
File.Copy(InterfacePath, InterfaceDLLName, overwrite);
}
catch (Exception e)
{
//intentionally using the fi
TGServerService.WriteError("Failed to update interface DLL! Error: " + e.ToString(), TGServerService.EventID.InterfaceDLLUpdateFail);
}
}
}
//used by Start and Watchdog to start a DD instance
+2
View File
@@ -70,6 +70,8 @@ namespace TGServerService
RepoPushFail = 5500,
RepoChangelog = 5600,
RepoChangelogFail = 5700,
InterfaceDLLUpdated = 5800,
InterfaceDLLUpdateFail = 5900,
ServiceShutdownFail = 6100,
WorldReboot = 6200,
ServerUpdateApplied = 6300,