开发者

Defeating CIFS file caching on Windows / forcing "refresh"

开发者 https://www.devze.com 2023-01-23 13:42 出处:网络
I\'m modifying files on a UNIX system and accessing them on a Windows box.The server runs samba and there is some amount of caching done by the client.When I modify the file on the UNIX side, the only

I'm modifying files on a UNIX system and accessing them on a Windows box. The server runs samba and there is some amount of caching done by the client. When I modify the file on the UNIX side, the only reliable way to see the new version of the file is to right click in Windows Explorer and select "refresh".

I'm looking for the Windows API equivalent of right-clicking in Windows Explorer an开发者_JAVA技巧d selecting "refresh". There are other questions on SO about sending a message to Explorer to cause it to refresh, but that's not what I want: I don't care about the contents of the Explorer window and I would prefer to not even need one open to the target directory. I just want to integrate the cache-defeating effect into my program so I avoid seeing stale data.


CIFS includes a notification system for updates. Explorer registers for this, and will reflect any changes that Samba sends it. I'm not aware of any other API mechanism to tell Windows that it needs to do a refresh.

Samba supports Linux inotify, so it should automatically pick up any changes to folders that Explorer is displaying and send Explorer updates.

Are you using a recent-enough version of Samba, and has Samba been built with inotify support? This is obviously Linux only. For another Unix, you could implement equivalent functionality. The relevant code is in smbd/notify_internal.c.

0

精彩评论

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

关注公众号