views:

495

answers:

3

So I'm in the middle of web-based filesystem abstraction layer development. Just like file browser, except it has some extra features like freaky permissions etc.

I would like users to be notified somehow about directory changes. So, i.e. when someone uploads a new file via FTP, certain users should get a proper message. It is not required for the message to be extra detailed, I don't really need to show the exact resource changed. The parent directory name should be enough.

What approach would you recommend?

+2  A: 

If your server is Linux you can do this with something like inotify

If the only updates are coming from FTP, then another solution I've used in the past is to write an add-on module to ProFTPD that performs the "notification" once upload is complete.

Van Gale
+1  A: 

See this question: http://stackoverflow.com/questions/479762/how-to-quickly-find-added-removed-files

But if you can control the upload somehow (i.e. use HTTP POST instead of FTP), you could simply send a notification after the upload has completed. This has the additional benefit that it would be simple to make sure users never see a partial file.

Aaron Digulla
I'd prefer FTP, since the files stored there are >200 MB each.
ohnoes
+1: Write the upload transaction. Write your own FTP client that adds notification.
S.Lott
S.Lott: sounds like reinveting the wheel. Besides, my users would crucify me if I asked them to use my own client ;)
ohnoes
S.Lott: You only need to hook into the server (-> Van Gale's answer)
Aaron Digulla
A: 

A simple approach would be to monitor/check the last modification date of the working directory (using os.stat() for example).

Whenever a file in a directory is modified, the working directory's (the directory the file is in) last modification date changes as well.

At least this works on the filesystems I am working on (ufs, ext3). I'm not sure if all filesystems do it this way.

Haes