From 29bc24004452477e73067b3211bb2c5f13bd909a Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 1 Jun 2016 16:15:55 -0700 Subject: [PATCH] Fix a timing issue in the polling watcher --- .../Internal/FileWatcher/PollingFileWatcher.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.Watcher.Core/Internal/FileWatcher/PollingFileWatcher.cs b/src/Microsoft.DotNet.Watcher.Core/Internal/FileWatcher/PollingFileWatcher.cs index d1f2dac231..a6ed82ce1c 100644 --- a/src/Microsoft.DotNet.Watcher.Core/Internal/FileWatcher/PollingFileWatcher.cs +++ b/src/Microsoft.DotNet.Watcher.Core/Internal/FileWatcher/PollingFileWatcher.cs @@ -117,13 +117,20 @@ namespace Microsoft.DotNet.Watcher.Core.Internal { var fileMeta = _knownEntities[fullFilePath]; - if (fileMeta.FileInfo.LastWriteTime != f.LastWriteTime) + try { - // File changed - RecordChange(f); - } + if (fileMeta.FileInfo.LastWriteTime != f.LastWriteTime) + { + // File changed + RecordChange(f); + } - _knownEntities[fullFilePath] = new FileMeta(fileMeta.FileInfo, true); + _knownEntities[fullFilePath] = new FileMeta(fileMeta.FileInfo, true); + } + catch(FileNotFoundException) + { + _knownEntities[fullFilePath] = new FileMeta(fileMeta.FileInfo, false); + } } _tempDictionary.Add(f.FullName, new FileMeta(f));