chokidar icon indicating copy to clipboard operation
chokidar copied to clipboard

Add Event Only Firing Once on WebDAV drive

Open joshbg2k opened this issue 6 years ago • 5 comments

Describe the bug

I am running Toshiba FlashAir SD cards as WebDAV drives on a local wireless network, and I have Chokidar running in an Electron (v1.7.5) environment. What I want to do is have Chokidar watch these drives for new files and copy them to the local disk.

I mount these drives over HTTP and verify that I can physically see new files being added to the drives. But if I start the watcher objects before mounting the drives, the add event only fire one time when the drive is mounted. Additionally, the raw event fires but does not appear to be detecting changes. I have tried adding the add event inside and outside of the ready event, which fires as normal.

The local machine (MacBook Pro) has read/write permissions on the remote drives, and WPA2 Personal is the security mode on the network. There is no authentication set up on the WebDAV drives, and on the MBP I connect to them as a guest.

Versions (please complete the following information):

  • Chokidar version 3.2.1
  • Node version 8.2.1
  • OS version: 10.14.4

To Reproduce:

You would need to have a Toshiba FlashAir card configured as a WebDAV drive and have Chokidar running in Electron. I have verified that the problem exists outside of Electron as well.

Here is the current config, I've tried several combinations of settings:

const watcherOptions = {
  // ignore dotfiles
  ignored: /(^|[\/\\])\../,
  usePolling: true,
  ignoreInitial: true,
  alwaysStat: false,
  followSymlinks: true,
  persistent: true,
  interval: 1000,
  binaryInterval: 2000,
  ignorePermissionErrors: true,
  awaitWriteFinish: {
    stabilityThreshold: 2000,
    pollInterval: 1000,
  },
  CHOKIDAR_USEPOLLING: 1,
  CHOKIDAR_INTERVAL: 1000,
};

Expected behavior Add event fire when a new file is added to WebDAV drive.

Additional context I'm not expecting that this environment actually be replicated for this issue, but if there are known network / drive behaviors that are expected to be configured in environments like this (WebDAV, wireless network), I'd really appreciate any help you're able to offer. From the research I've done, it seems like WebDAV should generally play nice with Chokidar.

joshbg2k avatar Oct 13 '19 16:10 joshbg2k

Nodejs 8.2 is not supported. Ensure you’re using 8.16 or even better, 10.x, since we’ll drop 8.x soon. That can resolve the issue.

paulmillr avatar Oct 13 '19 16:10 paulmillr

Thanks very much, I've updated Electron, as well as my global node installation, and I can confirm that it is working better than before in both. Now the add event fires, but only on the top level directory, not files contained within child directories - with or without the depth property. So I think I'm very close to a complete solution. Any further ideas?

joshbg2k avatar Oct 14 '19 04:10 joshbg2k

Try usePolling: false

paulmillr avatar Oct 14 '19 11:10 paulmillr

No luck with usePolling: false

However, with usePolling: false and ignoreInitial: false I do get add events when the watcher starts, but not subsequent adds. Here's the options object:

const watcherOptions = {
  usePolling: false,
};

const watcher = chokidar.watch('/Volumes/192.168.0.20', watcherOptions);

If there's any additional info that might help diagnose this issue I'm happy to provide it.

joshbg2k avatar Oct 15 '19 07:10 joshbg2k

Ok, it works! I added a glob to the first arg in the watch method:

const watcher = chokidar.watch('/Volumes/192.168.0.20/**/*', watcherOptions);

It seems like it's working perfectly now.

joshbg2k avatar Oct 16 '19 05:10 joshbg2k