Avoid crashing in PollingFileWatcher (#21544)

This commit is contained in:
Brennan 2020-05-06 15:47:50 -07:00 committed by GitHub
parent a9d702624a
commit 5fd4f87977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -188,7 +188,17 @@ namespace Microsoft.DotNet.Watcher.Internal
return;
}
var entities = dirInfo.EnumerateFileSystemInfos("*.*");
IEnumerable<FileSystemInfo> entities;
try
{
entities = dirInfo.EnumerateFileSystemInfos("*.*");
}
// If the directory is deleted after the exists check this will throw and could crash the process
catch (DirectoryNotFoundException)
{
return;
}
foreach (var entity in entities)
{
fileAction(entity);