mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 05:56:58 +01:00
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:
@@ -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
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace TGServerService
|
||||
RepoPushFail = 5500,
|
||||
RepoChangelog = 5600,
|
||||
RepoChangelogFail = 5700,
|
||||
InterfaceDLLUpdated = 5800,
|
||||
InterfaceDLLUpdateFail = 5900,
|
||||
ServiceShutdownFail = 6100,
|
||||
WorldReboot = 6200,
|
||||
ServerUpdateApplied = 6300,
|
||||
|
||||
Reference in New Issue
Block a user