Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix #143: ignore nonexistent files and directories on the iisnode\@wa…

…tchedFiles list
  • Loading branch information...
commit 077bce346b95c44ea097c3918fb99ab160d9ab69 1 parent db4b9d8
@tjanczuk tjanczuk authored
View
10 src/iisnode/cfilewatcher.cpp
@@ -142,7 +142,11 @@ HRESULT CFileWatcher::WatchFiles(PCWSTR mainFileName, PCWSTR watchedFiles, FileM
if (startFile != endFile)
{
- if (S_OK != (hr = this->WatchFile(directoryName, directoryLength, unc, startSubdirectory, startFile, endFile, wildcard)))
+ hr = this->WatchFile(directoryName, directoryLength, unc, startSubdirectory, startFile, endFile, wildcard);
+
+ // ignore files and directories that do not exist instead of failing
+
+ if (S_OK != hr && ERROR_FILE_NOT_FOUND != hr)
{
// still under lock remove file watch entries that were just created, then do regular cleanup
@@ -251,9 +255,9 @@ HRESULT CFileWatcher::GetWatchedFileTimestamp(WatchedFile* file, FILETIME* times
HRESULT CFileWatcher::WatchFile(PCWSTR directoryName, DWORD directoryNameLength, BOOL unc, PCWSTR startSubdirectoryName, PCWSTR startFileName, PCWSTR endFileName, BOOL wildcard)
{
HRESULT hr;
- WatchedFile* file;
+ WatchedFile* file = NULL;
WatchedDirectory* directory;
- WatchedDirectory* newDirectory;
+ WatchedDirectory* newDirectory = NULL;
// allocate new WatchedFile, get snapshot of the last write time
View
9 test/functional/tests/121_watchedFiles.js
@@ -0,0 +1,9 @@
+/*
+A simple GET request receives a hello world response despite watched files directories do not exist
+*/
+
+var iisnodeassert = require("iisnodeassert");
+
+iisnodeassert.sequence([
+ iisnodeassert.get(10000, "/121_watchedFiles/hello.js", 200, "Hello, world!")
+]);
View
6 test/functional/www/121_watchedFiles/hello.js
@@ -0,0 +1,6 @@
+var http = require('http');
+
+http.createServer(function (req, res) {
+ res.writeHead(200, {'Content-Type': 'text/html'});
+ res.end('Hello, world!');
+}).listen(process.env.PORT);
View
8 test/functional/www/121_watchedFiles/web.config
@@ -0,0 +1,8 @@
+<configuration>
+ <system.webServer>
+ <handlers>
+ <add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
+ </handlers>
+ <iisnode watchedFiles="*.js;idontexist\*"/>
+ </system.webServer>
+</configuration>
Please sign in to comment.
Something went wrong with that request. Please try again.