[PTRun][Program]Fix FileSystemWatcher Crash (#15480)

* fix FileSystemWatcher crash

* catch general exception
This commit is contained in:
Davide Giacometti
2022-01-17 23:56:04 +01:00
committed by GitHub
parent ba431c5bfd
commit 5035dc6754

View File

@@ -40,9 +40,15 @@ namespace Microsoft.Plugin.Program.Storage
var invalidPaths = new List<string>();
foreach (var path in paths)
{
if (!Directory.Exists(path))
try
{
Log.Warn($"Directory {path} does not exist and will be ignored", typeof(Win32ProgramFileSystemWatchers));
Directory.GetFiles(path);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
Log.Exception($"Failed to get files in {path}", ex, typeof(Win32ProgramFileSystemWatchers));
invalidPaths.Add(path);
}
}