[Enhancement]: Switch from inotify to alternative for CIFS shares #2282

Closed
opened 2026-04-25 00:05:45 +02:00 by adam · 5 comments
Owner

Originally created by @KaiStarkk on GitHub (Sep 29, 2024).

Type of Enhancement

Server Backend

Describe the Feature/Enhancement

CIFS mounts apparently aren't able to detect SMB2+ change_notify events for Linux clients.
Incidentally, this is not the case for Windows clients using ReadDirectoryChangesW.

For this reason, it would be nice to have a polling alternative for Linux (or docker) clients such as:

I could be wrong, but it appears that the built in scanner is more resource intensive and slow than above tools which would be based on stat. If I am wrong there this FR is redundant.

Why would this be helpful?

This would prevent having to manually scan libraries after books are added.

Future Implementation (Screenshot)

N/A

Audiobookshelf Server Version

v2.13.3

Current Implementation (Screenshot)

No response

Originally created by @KaiStarkk on GitHub (Sep 29, 2024). ### Type of Enhancement Server Backend ### Describe the Feature/Enhancement CIFS mounts apparently aren't able to detect SMB2+ `change_notify` events for Linux clients. Incidentally, this is not the case for Windows clients using `ReadDirectoryChangesW`. For this reason, it would be nice to have a polling alternative for Linux (or docker) clients such as: - Facebook watchman (polling) - https://github.com/clarabstract/watchntouch - https://fileschanged.sourceforge.net/ - https://github.com/emcrisostomo/fswatch I could be wrong, but it appears that the built in scanner is more resource intensive and slow than above tools which would be based on `stat`. If I am wrong there this FR is redundant. ### Why would this be helpful? This would prevent having to manually scan libraries after books are added. ### Future Implementation (Screenshot) N/A ### Audiobookshelf Server Version v2.13.3 ### Current Implementation (Screenshot) _No response_
adam added the enhancement label 2026-04-25 00:05:45 +02:00
adam closed this issue 2026-04-25 00:05:45 +02:00
Author
Owner

@advplyr commented on GitHub (Sep 29, 2024):

Abs uses watcher to watch for file changes.

I'm not sure we want to add in polling due to how large some users libraries are. Keeping the record of and polling 100k+ files I can imagine being very expensive, especially over NFS. I would be curious how other media servers handle this.

We wouldn't use the libraries you shared because Abs is built with nodejs.

@advplyr commented on GitHub (Sep 29, 2024): Abs uses [watcher](https://github.com/fabiospampinato/watcher) to watch for file changes. I'm not sure we want to add in polling due to how large some users libraries are. Keeping the record of and polling 100k+ files I can imagine being very expensive, especially over NFS. I would be curious how other media servers handle this. We wouldn't use the libraries you shared because Abs is built with nodejs.
Author
Owner

@mikiher commented on GitHub (Sep 29, 2024):

For the record, here's a discussion around this topic from an older bug.

@mikiher commented on GitHub (Sep 29, 2024): For the record, here's a [discussion around this topic](https://github.com/advplyr/audiobookshelf/issues/2349#issuecomment-1826873546) from an older bug.
Author
Owner

@KaiStarkk commented on GitHub (Sep 30, 2024):

Thanks @mikiher . I like the groundwork you've laid for a Windows watcher, I'll eventually do something similar for Linux hosts (which should also cover TrueNAS Scale) and maybe some of the BSD NAS OSs.

@advplyr One thing that would help a lot would be an API endpoint or payload in the scan endpoint to specify a directory to be scanned, rather than the whole library. That would make things much more responsive. I assume this is what the server already does internally when the watcher detects a change? Happy to look into it

@KaiStarkk commented on GitHub (Sep 30, 2024): Thanks @mikiher . I like the groundwork you've laid for a Windows watcher, I'll eventually do something similar for Linux hosts (which should also cover TrueNAS Scale) and maybe some of the BSD NAS OSs. @advplyr One thing that would help a lot would be an API endpoint or payload in the scan endpoint to specify a directory to be scanned, rather than the whole library. That would make things much more responsive. I assume this is what the server already does internally when the watcher detects a change? Happy to look into it
Author
Owner

@mikiher commented on GitHub (Oct 2, 2024):

When I wrote AbsWatcher, we opened an endpoint, /watcher/update for doing something very similar to what you describe. AbsWatcher is using it (it is currently undocumented, without good reason). It is implemented here

I thought a little bit in the past on how to generalize AbsWatcher to run on any file-serving system:

AbsWatcher has the advantage that Audiobookshelf Windows Docker and the files it serves are on the same system, so it has access to the docker command, which it uses to find the mapping between docker volumes and their respective windows folders. But if you're able to provide that mapping yourself (either manually or programmatically), the rest of the code (watching directories, notifying ABS through the API when changes happen) remains the same.

@mikiher commented on GitHub (Oct 2, 2024): When I wrote AbsWatcher, we opened an endpoint, `/watcher/update` for doing something very similar to what you describe. AbsWatcher is using it (it is currently undocumented, without good reason). It is implemented [here](https://github.com/advplyr/audiobookshelf/blob/fefc16bd137eb415cae14f58c761395dc9c19a90/server/controllers/MiscController.js#L544-L579) I thought a little bit in the past on how to generalize AbsWatcher to run on any file-serving system: AbsWatcher has the advantage that Audiobookshelf Windows Docker and the files it serves are on the same system, so it has access to the docker command, which it uses to find the mapping between docker volumes and their respective windows folders. But if you're able to provide that mapping yourself (either manually or programmatically), the rest of the code (watching directories, notifying ABS through the API when changes happen) remains the same.
Author
Owner

@KaiStarkk commented on GitHub (Oct 5, 2024):

@mikiher ah fantastic, thank you. I've implemented a generic solution and submitted a PR in case it's desired.

Much appreciated, saved me reinventing the wheel! Now I just need to figure out how to package it as a TrueNAS app.

@KaiStarkk commented on GitHub (Oct 5, 2024): @mikiher ah fantastic, thank you. I've implemented a generic solution and submitted a [PR](https://github.com/mikiher/abswatcher/pull/1) in case it's desired. Much appreciated, saved me reinventing the wheel! Now I just need to figure out how to package it as a TrueNAS app.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2282