C#: Make `GetCSharpArgsLogs` robust against log directory not existing

This commit is contained in:
Tom Hvitved 2021-10-08 13:21:21 +02:00
Родитель c75e2d306d
Коммит 61973c399e
1 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -492,8 +492,18 @@ namespace Semmle.Extraction.CSharp
/// <summary>
/// Gets a list of all `csharp.{hash}.txt` files currently written to the log directory.
/// </summary>
public static IEnumerable<string> GetCSharpArgsLogs() =>
Directory.EnumerateFiles(GetCSharpLogDirectory(), "csharp.*.txt");
public static IEnumerable<string> GetCSharpArgsLogs()
{
try
{
return Directory.EnumerateFiles(GetCSharpLogDirectory(), "csharp.*.txt");
}
catch (DirectoryNotFoundException)
{
// If the directory does not exist, there are no log files
return Enumerable.Empty<string>();
}
}
private static string GetCSharpLogDirectory()
{