Java WatchService在查看映射驱动器时不生成事件 [英] Java WatchService not generating events while watching mapped drives

查看:219
本文介绍了Java WatchService在查看映射驱动器时不生成事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个文件监视器但是我注意到java nio文件监视器不会为映射驱动器上复制的文件生成事件。例如,我在Unix上运行文件观察器来查看映射到Windows上的本地目录( / sharedfolder )( H:\ ),然后我在这个目录中放了一个文件( H:\ ),但文件观察者没有生成任何事件。现在如果我在Windows上运行文件观察器来监视映射的驱动器( H:\ ),它引用了一个unix路径( / sharedfolder )从unix我把文件放在这个文件夹中,文件监视器识别变化并生成一个事件。它看起来像一个bug,或者可能是我遗漏了一些东西,有什么想法吗?

I implemented a file watcher but I noticed that java nio file watcher doesn't generate events for files being copied on mapped drives. For instance, I've run the file watcher on Unix to watch a local directory (/sharedfolder) which is mapped on windows (H:\), and then I've put a file in this directory (H:\) but the file watcher hasn't generated any event. Now if I run the file watcher on windows to watcher the mapped drive (H:\) which refers to a unix path (/sharedfolder) and from unix I put a file in this folder, the file watcher identifies the change and generates an event. It looks like a bug, or may be I'm missing some thing, any thoughts?

推荐答案

我有同样的问题尝试通过CIFS观看已安装的Windows共享。
似乎无法获得CIFS的文件系统事件安装

I have the same issue trying to watch a mounted windows share via CIFS. It seems not possible to get filesystem events for CIFS mounts.

Java 7 NIO FileWatcher的linux实现使用 inotify 。 Inotify是一个Linux内核子系统,用于注意文件系统更改,这对于本地目录非常有用,但显然不适用于 CIFS安装

The linux implementation of the Java 7 NIO FileWatcher uses inotify. Inotify is a linux kernel subsystem to notice filesystem changes which works perfect for local directories, but apparently not for CIFS mounts.

在Oracle,修复此错误。 (这是他们的责任吗?更多的操作系统问题......)

At Oracle, it doesn't seem to be high priority to fix this bug. (Is it their responsibility? More of an OS issue...)

JNotify 也在linux系统上使用 inotify ,所以这也没有选择。

JNotify also uses inotify on linux systems, so this is no option either.

所以映射驱动器监控不幸似乎仅限于投票人:

So mapped drives monitoring unfortunately seems to be limited to pollers:


  • Apache VFS DefaultFileMonitor 用于轮询目录(已安装的共享)

  • 基于标准Java API的文件轮询器。

  • 使用 jCIFS 自定义文件轮询器(因此共享不需要安装在主机上)

  • Apache VFS DefaultFileMonitor to poll directories (mounted share)
  • File Poller based on the standard Java API.
  • Custom File Poller with jCIFS (so the share doesn't need to be mounted on the host)

我可能会尝试Apache VFS Monitor,因为它会检测文件创建,更新和删除的盒子。它需要挂载共享,但这使操作系统负责CIFS连接而不是我的应用程序。

I'll probably try the Apache VFS Monitor, because it detects file creation, updates and deletes out of the box. It requires to mount the share, but that gives the OS the responsibility of CIFS connections and not my application.

这篇关于Java WatchService在查看映射驱动器时不生成事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆