Skip to content

Commit

Permalink
fix #143: ignore nonexistent files and directories on the iisnode\@wa…
Browse files Browse the repository at this point in the history
…tchedFiles list
  • Loading branch information
tjanczuk committed Feb 28, 2012
1 parent db4b9d8 commit 077bce3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/iisnode/cfilewatcher.cpp
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions 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!")
]);
6 changes: 6 additions & 0 deletions 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);
8 changes: 8 additions & 0 deletions 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>

0 comments on commit 077bce3

Please sign in to comment.