Fix installation directory instance detection.

This commit is contained in:
Cyberboss
2020-01-12 18:30:38 -05:00
parent c10cc57808
commit a35a2bed3f
@@ -130,7 +130,14 @@ namespace Tgstation.Server.Host.Controllers
}, out var normalizedLocalPath);
if (rawPath.StartsWith(normalizedLocalPath, StringComparison.Ordinal))
return Conflict("Instances cannot be created in the installation directory!");
{
bool sameLength = rawPath.Length == normalizedLocalPath.Length;
char dirSeparatorChar = rawPath.ToCharArray()[normalizedLocalPath.Length];
if(sameLength
|| dirSeparatorChar == Path.DirectorySeparatorChar
|| dirSeparatorChar == Path.AltDirectorySeparatorChar)
return Conflict(new ErrorMessage { Message = "Instances cannot be created in the installation directory!" });
}
var dirExistsTask = ioManager.DirectoryExists(model.Path, cancellationToken);
bool attached = false;