SpartanJ / efsw

efsw is a C++ cross-platform file system watcher and notifier.
Other
645 stars 98 forks source link

Generic file watcher doesn't report new directories on network drives #173

Closed matschu closed 6 months ago

matschu commented 6 months ago

The generic file watcher detects but doesn't report new directories inside of a watched directory if that directory is on a network drive. Deleted or modified directories are reported as expected.

Assuming a directory structure like

watched_dir/
├─ new_dir/

on a remote filesystem, the folder new_dir is not reported after its creation. The debugger shows that the new directory is in fact detected but DirWatcherGeneric::createDirectory explicitly discards the directory because it is on a remote file system.

I'm not sure if this is a bug or intentional but after removing FileSystem::isRemoteFS( dir ) everything seems to work as expected.

SpartanJ commented 6 months ago

Hi! Yes, it's intentional basically because watching a remote directory tree is extremely slow. I know it can work in some cases, but it's dangerous. The generic file watcher will scan every single directory watched for changes, this is computationally expensive, and for networks this is usually too slow, since you depend on the network latency. This file watcher was developed basically as a reference for the file watchers but it's not intended to be used in production scenarios. But feel free to make any adjustments for your needs, that's why it's open source :)

matschu commented 6 months ago

Thank you for the clarification – I did indeed not think about the runtime cost being the reason for this check.