From 8950cc1a3684e0df64aebe5a67b2debc01f6ef7e Mon Sep 17 00:00:00 2001 From: Dominion Date: Mon, 5 Jun 2023 17:14:11 -0400 Subject: [PATCH] Catch potential IOExceptions when listing a config directory --- .../Components/StaticFiles/Configuration.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index 55a8aba459..5e7391a6fc 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -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))