开发者

Update database when file is added

开发者 https://www.devze.com 2022-12-18 10:36 出处:网络
Having开发者_C百科 a server(ish) I want a way to keep track of the files I have in some folders with a web-interface. I have done most of the programming already, by basically parsing through the fold

Having开发者_C百科 a server(ish) I want a way to keep track of the files I have in some folders with a web-interface. I have done most of the programming already, by basically parsing through the folders each load ( not the most optimized way but it has had it advantages as well ). But now the reasons of keeping the files in a database has become overwhelming.

So - How do I do this in the best way possible.

The way I had thought was to have a script running and add a database entry whenever a file was added to a folder I was listening to. Is there an easy way to accomplish this? Or would you solve this problem in a completely different matter?

edit: right sorry. Operating system is a bit difficult - not really. But at the moment it's written on an os x machine but eventually it's going up on an linux so I'll absolutely have a look at inotify. Do you know any others like it for say os x.


One way to do this is to create a Windows Service (which runs all the time) that contains a FileWatcher component (I think it's called this). When a new file is detected, make a call to your database.


Use incron to run a script to update the database whenever a file is added or removed.


You mention using OS X - you can use the File System Events library.

On linux, you'd use inotify (perhaps using a wrapper such as incron, which another poster mentioned).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号