Skip to content

Commit 077bce3

Browse files
committed
fix #143: ignore nonexistent files and directories on the iisnode\@watchedFiles list
1 parent db4b9d8 commit 077bce3

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

Diff for: src/iisnode/cfilewatcher.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ HRESULT CFileWatcher::WatchFiles(PCWSTR mainFileName, PCWSTR watchedFiles, FileM
142142

143143
if (startFile != endFile)
144144
{
145-
if (S_OK != (hr = this->WatchFile(directoryName, directoryLength, unc, startSubdirectory, startFile, endFile, wildcard)))
145+
hr = this->WatchFile(directoryName, directoryLength, unc, startSubdirectory, startFile, endFile, wildcard);
146+
147+
// ignore files and directories that do not exist instead of failing
148+
149+
if (S_OK != hr && ERROR_FILE_NOT_FOUND != hr)
146150
{
147151
// still under lock remove file watch entries that were just created, then do regular cleanup
148152

@@ -251,9 +255,9 @@ HRESULT CFileWatcher::GetWatchedFileTimestamp(WatchedFile* file, FILETIME* times
251255
HRESULT CFileWatcher::WatchFile(PCWSTR directoryName, DWORD directoryNameLength, BOOL unc, PCWSTR startSubdirectoryName, PCWSTR startFileName, PCWSTR endFileName, BOOL wildcard)
252256
{
253257
HRESULT hr;
254-
WatchedFile* file;
258+
WatchedFile* file = NULL;
255259
WatchedDirectory* directory;
256-
WatchedDirectory* newDirectory;
260+
WatchedDirectory* newDirectory = NULL;
257261

258262
// allocate new WatchedFile, get snapshot of the last write time
259263

Diff for: test/functional/tests/121_watchedFiles.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
A simple GET request receives a hello world response despite watched files directories do not exist
3+
*/
4+
5+
var iisnodeassert = require("iisnodeassert");
6+
7+
iisnodeassert.sequence([
8+
iisnodeassert.get(10000, "/121_watchedFiles/hello.js", 200, "Hello, world!")
9+
]);

Diff for: test/functional/www/121_watchedFiles/hello.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var http = require('http');
2+
3+
http.createServer(function (req, res) {
4+
res.writeHead(200, {'Content-Type': 'text/html'});
5+
res.end('Hello, world!');
6+
}).listen(process.env.PORT);

Diff for: test/functional/www/121_watchedFiles/web.config

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<configuration>
2+
<system.webServer>
3+
<handlers>
4+
<add name="iisnode" path="hello.js" verb="*" modules="iisnode" />
5+
</handlers>
6+
<iisnode watchedFiles="*.js;idontexist\*"/>
7+
</system.webServer>
8+
</configuration>

0 commit comments

Comments
 (0)