commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steven Keens" <>
Subject RE: [vfs] DefaultFileMonitor doesn't signal when a file is created.
Date Wed, 22 Nov 2006 23:53:56 GMT

> | I put a monitor on a configuration file (not a folder).  During
> testing
> | I noticed that the monitoring doesn't recognize when the file is
> | created.  I get changed and deleted events but never a created
> This seems pretty intuitive to me, how can you monitor something that
> isn't there?  Although I do think it would be nice if setting up a
> monitor for a file that didn't exist would revert to monitoring the
> containing context for a creation event.

I guess we don't have the same intuition.  My first instinct assumed
that the created event would be sent.  In fact it took me a good hour to
realize what was going on.  I checked my code twice before assuming the
problem was with VFS.  This just proves my favorite expression - common
sense is not so common.

Setting up a monitor for the containing context produces events for
other files that I don't care about.  And that means more work in the
listener to filter out the junk.  Also, monitoring a folder uses more
resources because it has to check all of the children.  I think it would
be simple to implement.  Send a created event if the file didn't exist
during the previous test and now it exists.  The test is simple because
of the FileObject.exists() function.

The only issue I see with this is backwards compatibility.  Changing the
behavior might break everyone else's applications using the
DefaultFileMonitor as it stands now.  To me that's the only valid reason
not to change the behavior.  And if the behavior doesn't change then
I'll likely implement something myself based on the DefaultFileMonitor.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message