Skip to content

Commit ed70bc8

Browse files
committed
Check if compiler exists before getting version info
1 parent 7e84242 commit ed70bc8

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/PluginCompiler.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ private static void UpdateCheck()
193193

194194
private static void SetCompilerVersion()
195195
{
196-
var version = FileVersionInfo.GetVersionInfo(BinaryPath);
197-
CompilerVersion = $"{version.FileMajorPart}.{version.FileMinorPart}.{version.FileBuildPart}.{version.FilePrivatePart}";
196+
CompilerVersion = File.Exists(BinaryPath) ? FileVersionInfo.GetVersionInfo(BinaryPath).FileVersion : "Unknown";
198197
RemoteLogger.SetTag("compiler version", CompilerVersion);
199198
}
200199

@@ -254,7 +253,7 @@ private void EnqueueCompilation(Compilation compilation)
254253

255254
if (!CheckCompiler())
256255
{
257-
OnCompilerFailed($"compiler v{CompilerVersion} couldn't be started");
256+
OnCompilerFailed($"compiler version {CompilerVersion} couldn't be started");
258257
return;
259258
}
260259

@@ -282,7 +281,7 @@ private void OnMessage(ObjectStreamConnection<CompilerMessage, CompilerMessage>
282281
{
283282
Interface.Oxide.NextTick(() =>
284283
{
285-
OnCompilerFailed($"compiler v{CompilerVersion} disconnected");
284+
OnCompilerFailed($"compiler version {CompilerVersion} disconnected");
286285
DependencyTrace();
287286
Shutdown();
288287
});
@@ -418,7 +417,7 @@ private bool CheckCompiler()
418417
{
419418
process?.Dispose();
420419
process = null;
421-
Interface.Oxide.LogException($"Exception while starting compiler v{CompilerVersion}: ", ex);
420+
Interface.Oxide.LogException($"Exception while starting compiler version {CompilerVersion}: ", ex);
422421
if (BinaryPath.Contains("'")) Interface.Oxide.LogWarning("Server directory path contains an apostrophe, compiler will not work until path is renamed");
423422
else if (Environment.OSVersion.Platform == PlatformID.Unix) Interface.Oxide.LogWarning("Compiler may not be set as executable; chmod +x or 0744/0755 required");
424423
if (ex.GetBaseException() != ex) Interface.Oxide.LogException("BaseException: ", ex.GetBaseException());
@@ -439,7 +438,7 @@ private void OnProcessExited(object sender, EventArgs eventArgs)
439438
{
440439
Interface.Oxide.NextTick(() =>
441440
{
442-
OnCompilerFailed($"compiler v{CompilerVersion} was closed unexpectedly");
441+
OnCompilerFailed($"compiler version {CompilerVersion} was closed unexpectedly");
443442

444443
if (Environment.OSVersion.Platform == PlatformID.Unix)
445444
{

0 commit comments

Comments
 (0)