击败 Windows 上的 CIFS 文件缓存/强制“刷新”

发布于 2024-09-30 11:42:15 字数 284 浏览 0 评论 0原文

我正在 UNIX 系统上修改文件并在 Windows 机器上访问它们。服务器运行 samba,并且客户端执行一定量的缓存。当我在 UNIX 端修改文件时,查看文件新版本的唯一可靠方法是在 Windows 资源管理器中右键单击并选择“刷新”。

我正在寻找相当于在 Windows 资源管理器中右键单击并选择“刷新”的 Windows API。还有其他关于向资源管理器发送消息以使其刷新的问题,但这不是我想要的:我不关心资源管理器窗口的内容,我什至不需要打开目标目录。我只是想将破坏缓存的效果集成到我的程序中,这样我就可以避免看到过时的数据。

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 and 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉梦枕江山 2024-10-07 11:42:15

CIFS 包括更新通知系统。 Explorer 对此进行注册,并将反映 Samba 发送给它的任何更改。我不知道有任何其他 API 机制可以告诉 Windows 它需要进行刷新。

Samba 支持 Linux inotify,因此它应该自动获取对 Explorer 正在显示的文件夹的任何更改,并发送 Explorer 更新。

您是否使用足够新的 Samba 版本,并且 Samba 是否带有 inotify 支持?这显然仅限于 Linux。对于另一个 Unix,您可以实现等效的功能。相关代码位于smbd/notify_internal.c中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文