New error code for if you try to set a bad project name

This commit is contained in:
Jordan Dominion
2024-07-26 17:04:21 -04:00
parent dfbc6abc07
commit d11dc01537
4 changed files with 35 additions and 3 deletions
+3 -3
View File
@@ -5,10 +5,10 @@
<PropertyGroup>
<TgsCoreVersion>6.7.0</TgsCoreVersion>
<TgsConfigVersion>5.1.0</TgsConfigVersion>
<TgsApiVersion>10.5.0</TgsApiVersion>
<TgsApiVersion>10.6.0</TgsApiVersion>
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
<TgsApiLibraryVersion>13.5.0</TgsApiLibraryVersion>
<TgsClientVersion>15.5.0</TgsClientVersion>
<TgsApiLibraryVersion>13.6.0</TgsApiLibraryVersion>
<TgsClientVersion>15.6.0</TgsClientVersion>
<TgsDmapiVersion>7.1.3</TgsDmapiVersion>
<TgsInteropVersion>5.9.0</TgsInteropVersion>
<TgsHostWatchdogVersion>1.4.1</TgsHostWatchdogVersion>
@@ -651,5 +651,11 @@ namespace Tgstation.Server.Api.Models
/// </summary>
[Description("Could not create dump as dotnet diagnostics threw an exception!")]
DotnetDiagnosticsFailure,
/// <summary>
/// The configured .dme could not be found.
/// </summary>
[Description("Could not load configured .dme due to it being outside the deployment directory! This should be a relative path.")]
DeploymentWrongDme,
}
}
@@ -610,6 +610,9 @@ namespace Tgstation.Server.Host.Components.Deployment
var targetDmeExists = await ioManager.FileExists(targetDme, cancellationToken);
if (!targetDmeExists)
throw new JobException(ErrorCode.DeploymentMissingDme);
if (!await ioManager.PathIsChildOf(outputDirectory, targetDme, cancellationToken))
throw new JobException(ErrorCode.DeploymentWrongDme);
}
logger.LogDebug("Selected \"{dmeName}.dme\" for compilation!", job.DmeName);
@@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -200,6 +202,27 @@ namespace Tgstation.Server.Tests.Live.Instance
deployJob = await dreamMakerClient.Compile(cancellationToken);
await WaitForJob(deployJob, 40, true, ErrorCode.DeploymentMissingDme, cancellationToken);
// set to an absolute path that does exist
var tempFile = Path.GetTempFileName().Replace('\\', '/');
try
{
// for testing purposes, assume same drive for windows
var relativePath = $"../../{String.Join("/", instanceClient.Metadata.Path.Replace('\\', '/').Where(pathChar => pathChar == '/').Select(x => ".."))}{tempFile.Substring(tempFile.IndexOf('/'))}";
var dmePath = $"{tempFile}.dme";
File.Move(tempFile, dmePath);
tempFile = dmePath;
await dreamMakerClient.Update(new DreamMakerRequest
{
ProjectName = relativePath
}, cancellationToken);
deployJob = await dreamMakerClient.Compile(cancellationToken);
await WaitForJob(deployJob, 40, true, ErrorCode.DeploymentWrongDme, cancellationToken);
}
finally
{
File.Delete(tempFile);
}
// check that we can change the visibility
await vpTest;