[p2p-hackers] keeping metadata synchronized
list-p2phack at ruffledpenguin.org
Sun Sep 19 20:48:57 UTC 2004
On Wed, 2004-09-15 at 07:51, Eric Hanson wrote:
> That's kind of what I was thinking, but I don't even know where
> to start looking on how to do it. It's going to be a Java app,
> so I can write a listener to listen for moves, deletes and
> renames and sync on that. But, say on a OSX box, is there an
> event thrown that can be tapped into somehow? How about
> Windows? How about Linux?
If you can use C# (at least for the fs daemon) you can take advantage of
a class called "FileSystemWatcher" which provides a nice eventing model
for changes to the monitored directory tree.
This should work on Win32, Linux, and OSX. It uses FAM on linux, the MS
implementation probably uses the native API for tracking changes, OSX
either uses some native change tracking API or uses polling.
All of these have the potential to drop changes if the change queue gets
too large (ex: you delete a large directory tree all at once or do a
large copy operation) and I'm not sure what recovery mechanisms are
available in the event of a drop. I would hope that you would see a
"directory changed, but I lost the detail under it" sort of message so
that you could re-walk that portion of the tree, but you would need to
Another issue is that FAM doesn't monitor entire trees, just
directories, and it has a hard limit on the number that it can monitor
at a time. I suspect they work around this by recursively adding
directories down the tree. Obviously this might cause problems with
large trees or multiple users of your application.
If you figure out all of the details of this, I'd be very curious to
hear about them. Even if you are unwilling to use the CLR class
libraries, you could probably port the Mono version of FileSystemWatcher
Hope that helps,
More information about the P2p-hackers