2

I have built an application with PHP which shows all the files in the home directory of a user this directory is also available via samba so you can access it from the native explorer in windows, mac and linux. I wanted to give every file an ID so that I can asign tags to every file how would you go about doing this? Would you make hashs of the file and look whether its the same filehash and would thus conclude that its the same file?

Can I trigger samba to send out something everytime a file or folder gets moved?

4

2 回答 2

0

要回答您的第一个问题,制作哈希当然可以。只需在文件上使用 md5 就足够了。散列主目录中的文件时发生冲突的可能性非常小。IMO 我什至会说不值得一提。它可能不言而喻,但是......我至少会存储散列和完整路径,这样你就可以适当地处理移动的文件,并实际对文件做一些事情

于 2009-06-19T20:21:57.957 回答
0

如果您的平台是 Linux 并且安装是相当新的,您可以使用 inotify 在文件系统发生更改时调用您的 PHP 代码。请参阅 PHP 手册的这一部分:

http://us3.php.net/manual/en/book.inotify.php

基本用法是在一个或多个 Samba 目录上添加一个监视程序,并回调您的 PHP 代码。出于性能原因,最好看看是否可以告诉 inotify 只将您感兴趣的更新类型发送到您的代码。

但请注意,inotify 将在一段时间后删除更新/消息。因此,您将在某个时间点保持同步时遇到问题。一种解决方案是持续使用 inotify,并定期对每个家庭进行全面扫描,以验证它是否反映了您的数据库(或存储标签的任何位置)。

于 2009-06-15T18:37:16.110 回答