mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 00:22:40 +01:00
Merge pull request #576 from Cyberboss/DoggingAlong
More watchdog testing
This commit is contained in:
@@ -186,6 +186,8 @@ Instances are DreamDaemon server configurations, they live in their own director
|
||||
|
||||
PUT "/Instance" @ref Tgstation.Server.Api.Models.Instance => @ref Tgstation.Server.Api.Models.Instance
|
||||
|
||||
This normally returns 201 BUT, in the case of attaching an existing instance, 200 will instead be returned
|
||||
|
||||
The user that creates an instance will be given full @ref Tgstation.Server.Api.Models.InstanceUser permission. The path must not exist at the time of creation. Support for attaching instances from backups is yet to come.
|
||||
|
||||
A specific Instance may be retrieved with:
|
||||
|
||||
@@ -866,7 +866,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
User = sender
|
||||
};
|
||||
|
||||
var json = JsonConvert.SerializeObject(arguments, new JsonSerializerSettings
|
||||
var json = JsonConvert.SerializeObject(commandObject, new JsonSerializerSettings
|
||||
{
|
||||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
});
|
||||
|
||||
@@ -111,9 +111,12 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|
||||
NormalizeModelPath(model, out var rawPath);
|
||||
var dirExistsTask = ioManager.DirectoryExists(model.Path, cancellationToken);
|
||||
bool attached = false;
|
||||
if (await ioManager.FileExists(model.Path, cancellationToken).ConfigureAwait(false) || await dirExistsTask.ConfigureAwait(false))
|
||||
if(!await ioManager.FileExists(ioManager.ConcatPath(model.Path, InstanceAttachFileName), cancellationToken).ConfigureAwait(false))
|
||||
if (!await ioManager.FileExists(ioManager.ConcatPath(model.Path, InstanceAttachFileName), cancellationToken).ConfigureAwait(false))
|
||||
return Conflict(new ErrorMessage { Message = "Path not empty!" });
|
||||
else
|
||||
attached = true;
|
||||
|
||||
var newInstance = new Models.Instance
|
||||
{
|
||||
@@ -181,9 +184,10 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return Conflict(new ErrorMessage{ Message = e.Message });
|
||||
}
|
||||
|
||||
Logger.LogInformation("{0} created instance {1}: {2}", AuthenticationContext.User.Name, newInstance.Name, newInstance.Id);
|
||||
|
||||
return StatusCode((int)HttpStatusCode.Created, newInstance.ToApi());
|
||||
Logger.LogInformation("{0} {1} instance {2}: {3} ({4})", AuthenticationContext.User.Name, attached ? "attached" : "created", newInstance.Name, newInstance.Id, newInstance.Path);
|
||||
|
||||
var api = newInstance.ToApi();
|
||||
return attached ? (IActionResult)Json(api) : StatusCode((int)HttpStatusCode.Created, api);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user