您如何使用应用程序跟踪 SMB 中的文件?

2022-01-24 00:00:00 debian php unix samba

我用 PHP 构建了一个应用程序,它显示了用户主目录中的所有文件,该目录也可以通过 samba 访问,因此您可以从 windows、mac 和 linux 中的本机资源管理器访问它.我想给每个文件一个 ID,这样我就可以为每个文件分配标签,你会怎么做呢?您是否会对文件进行哈希处理并查看它是否是相同的文件哈希并因此得出结论它是相同的文件?

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?

我可以在每次移动文件或文件夹时触发 samba 发送内容吗?

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

推荐答案

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

To answer your first question, making a hash would of course work. Simply using md5 on the files would be sufficient. The chances of a collision while hashing the files in your home directory are insanely small. IMO I would say not even worth mentioning. And it probably goes without saying but... I would store at least the hash and the full path, so you can deal with moved files appropriately, and actually do something with the file.

相关文章