Skip to content

Commit

Permalink
2009-03-11 Gonzalo Paniagua Javier <gonzalo@novell.com>
Browse files Browse the repository at this point in the history
	* InotifyWatcher.cs: don't send events when a directory is created
	unless it matches the pattern.  Fixes bug #484082.


svn path=/branches/mono-2-4-0/mcs/; revision=129114
  • Loading branch information
gonzalop committed Mar 12, 2009
1 parent 8f4c7c9 commit 27589b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
5 changes: 5 additions & 0 deletions mcs/class/System/System.IO/ChangeLog
@@ -1,3 +1,8 @@
2009-03-11 Gonzalo Paniagua Javier <gonzalo@novell.com>

* InotifyWatcher.cs: don't send events when a directory is created
unless it matches the pattern. Fixes bug #484082.

2009-01-26 Marek Habersack <mhabersack@novell.com>

* SearchPattern.cs: make IsMatch work for situations when there is
Expand Down
25 changes: 14 additions & 11 deletions mcs/class/System/System.IO/InotifyWatcher.cs
Expand Up @@ -291,10 +291,12 @@ static void StartMonitoringDirectory (InotifyData data, bool justcreated)
if (justcreated) {
lock (fsw) {
RenamedEventArgs renamed = null;
fsw.DispatchEvents (FileAction.Added, directory, ref renamed);
if (fsw.Waiting) {
fsw.Waiting = false;
System.Threading.Monitor.PulseAll (fsw);
if (fsw.Pattern.IsMatch (directory)) {
fsw.DispatchEvents (FileAction.Added, directory, ref renamed);
if (fsw.Waiting) {
fsw.Waiting = false;
System.Threading.Monitor.PulseAll (fsw);
}
}
}
}
Expand All @@ -311,14 +313,15 @@ static void StartMonitoringDirectory (InotifyData data, bool justcreated)
foreach (string filename in Directory.GetFiles (data.Directory)) {
lock (fsw) {
RenamedEventArgs renamed = null;
if (fsw.Pattern.IsMatch (filename)) {
fsw.DispatchEvents (FileAction.Added, filename, ref renamed);
/* If a file has been created, then it has been written to */
fsw.DispatchEvents (FileAction.Modified, filename, ref renamed);

fsw.DispatchEvents (FileAction.Added, filename, ref renamed);
/* If a file has been created, then it has been written to */
fsw.DispatchEvents (FileAction.Modified, filename, ref renamed);

if (fsw.Waiting) {
fsw.Waiting = false;
System.Threading.Monitor.PulseAll(fsw);
if (fsw.Waiting) {
fsw.Waiting = false;
System.Threading.Monitor.PulseAll(fsw);
}
}
}
}
Expand Down

0 comments on commit 27589b5

Please sign in to comment.