Catch potential IOExceptions when listing a config directory

This commit is contained in:
Dominion
2023-06-11 10:41:16 -04:00
parent 7e0d4a29b8
commit 8950cc1a36
@@ -227,28 +227,28 @@ namespace Tgstation.Server.Host.Components.StaticFiles
void ListImpl()
{
var enumerator = synchronousIOManager.GetDirectories(path, cancellationToken);
try
{
var enumerator = synchronousIOManager.GetDirectories(path, cancellationToken);
result.AddRange(enumerator.Select(x => new ConfigurationFileResponse
{
IsDirectory = true,
Path = ioManager.ConcatPath(configurationRelativePath, x),
}).OrderBy(file => file.Path));
enumerator = synchronousIOManager.GetFiles(path, cancellationToken);
result.AddRange(enumerator.Select(x => new ConfigurationFileResponse
{
IsDirectory = false,
Path = ioManager.ConcatPath(configurationRelativePath, x),
}).OrderBy(file => file.Path));
}
catch (IOException e)
catch (IOException ex)
{
logger.LogDebug(e, "IOException while writing {path}!", path);
logger.LogDebug(ex, "IOException while enumerating direcotry!");
result = null;
return;
}
enumerator = synchronousIOManager.GetFiles(path, cancellationToken);
result.AddRange(enumerator.Select(x => new ConfigurationFileResponse
{
IsDirectory = false,
Path = ioManager.ConcatPath(configurationRelativePath, x),
}).OrderBy(file => file.Path));
}
using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken))