Fix configuration conflict exceptions

This commit is contained in:
Cyberboss
2018-08-31 11:26:11 -04:00
parent a3960a8a89
commit b614964c8a
3 changed files with 21 additions and 10 deletions
@@ -216,10 +216,6 @@ namespace Tgstation.Server.Host.Components.StaticFiles
Path = configurationRelativePath
};
}
catch (IOException e)
{
logger.LogDebug("IOException while reading {0}: {1}", path, e);
}
catch (UnauthorizedAccessException)
{
//this happens on windows, dunno about linux
@@ -308,10 +304,6 @@ namespace Tgstation.Server.Host.Components.StaticFiles
Path = configurationRelativePath
};
}
catch (IOException e)
{
logger.LogDebug("IOException while writing {0}: {1}", path, e);
}
catch (UnauthorizedAccessException)
{
//this happens on windows, dunno about linux
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.IO;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
@@ -54,12 +55,23 @@ namespace Tgstation.Server.Host.Controllers
{
var newFile = await config.Write(model.Path, AuthenticationContext.SystemIdentity, model.Content, model.LastReadHash, cancellationToken).ConfigureAwait(false);
if (newFile == null)
return Conflict();
return Conflict(new ErrorMessage
{
Message = ""
});
newFile.Content = null;
return model.LastReadHash == null ? (IActionResult)StatusCode((int)HttpStatusCode.Created, newFile) : Json(newFile);
}
catch(IOException e)
{
Logger.LogInformation("IOException while updating file {0}: {1}", model.Path, e);
return Conflict(new ErrorMessage
{
Message = e.Message
});
}
catch (NotImplementedException)
{
return StatusCode((int)HttpStatusCode.NotImplemented);
@@ -87,6 +99,14 @@ namespace Tgstation.Server.Host.Controllers
return Json(result);
}
catch (IOException e)
{
Logger.LogInformation("IOException while reading file {0}: {1}", filePath, e);
return Conflict(new ErrorMessage
{
Message = e.Message
});
}
catch (NotImplementedException)
{
return StatusCode((int)HttpStatusCode.NotImplemented);
@@ -330,7 +330,6 @@ namespace Tgstation.Server.Host.Controllers
var api = canRead ? currentModel.ToApi() : new Repository();
var repoManager = instanceManager.GetInstance(Instance).RepositoryManager;
if (canRead)
{
if (repoManager.CloneInProgress)