From 5be13279cb1e430eb9e4c9ce1b7af15416179ef7 Mon Sep 17 00:00:00 2001 From: Salvador Guerrero Date: Tue, 19 Jul 2016 23:24:18 -0600 Subject: [PATCH] Fixes an issue in DirectoryWatcher where it stops listening for events after a batch deletion --- Foundation/src/DirectoryWatcher.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Foundation/src/DirectoryWatcher.cpp b/Foundation/src/DirectoryWatcher.cpp index 12149ea4a..0a59c82f6 100644 --- a/Foundation/src/DirectoryWatcher.cpp +++ b/Foundation/src/DirectoryWatcher.cpp @@ -108,7 +108,20 @@ protected: DirectoryIterator end; while (it != end) { - entries[it.path().getFileName()] = ItemInfo(*it); + // DirectoryWatcher should not stop watching if it fails to get the info + // of a file, it should just ignore it. + try + { + entries[it.path().getFileName()] = ItemInfo(*it); + } + catch(const Poco::FileNotFoundException& fnfe) + { + // The file is missing, remove it from the entries so it is treated as + // deleted. + entries.erase(it.path().getFileName()); + + poco_unexpected(); + } ++it; } }