From eb52529ff41d375344c2bd45a717bf86669627f8 Mon Sep 17 00:00:00 2001 From: Vladimir Penev Date: Thu, 1 Nov 2018 07:21:35 -0400 Subject: server: Fix assertion failure on directory paths in file monitor Fixes: #18532 --- Source/cmFileMonitor.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 04a3c0e..b36ac78 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -315,6 +315,7 @@ void cmFileMonitor::MonitorPaths(const std::vector& paths, for (std::string const& p : paths) { std::vector pathSegments; cmsys::SystemTools::SplitPath(p, pathSegments, true); + const bool pathIsFile = !cmsys::SystemTools::FileIsDirectory(p); const size_t segmentCount = pathSegments.size(); if (segmentCount < 2) { // Expect at least rootdir and filename @@ -324,7 +325,7 @@ void cmFileMonitor::MonitorPaths(const std::vector& paths, for (size_t i = 0; i < segmentCount; ++i) { assert(currentWatcher); - const bool fileSegment = (i == segmentCount - 1); + const bool fileSegment = (i == segmentCount - 1 && pathIsFile); const bool rootSegment = (i == 0); assert( !(fileSegment && -- cgit v0.12