I recently encountered some confusing behaviour with regards to “top-level include patterns” on an Android device. The docs appear to incorrectly describe filesystem watching behaviour when a non “top-level include pattern” is used.
Here is a shortened version of my ignore file. In summary, only certain folders were synchronized, with everything else ignored. All include patterns were top-level. Filesystem watching was initially disabled.
!/DCIM
!/Download
!/Pictures
*
Following this, I decided to handle /DCIM/Camera in a separate partnership. My ignore list became this:
/DCIM/Camera # exclude the Camera folder in DCIM
!/DCIM # everything else in DCIM
!/Download
!/Pictures
*
No problems so far. Because this device is always plugged in and battery life is not a concern I decided to enable filesystem watching. Immediately syncthing popped up a “Filesystem Watcher Error”: permission denied traversing /storage/emulated/0/Android/obb
Here is what the docs say:
Top-level include patterns are described as not [causing syncthing to] “scan” [the entire directory tree]
Non top-level include patterns are described as [causing syncthing to] “traverse” and “watch” [the entire directory tree].
I run some tests.
- Filesystem watching is enabled.
- I use a non top-level include pattern. Hence, syncthing traversed the entire directory tree.
- Syncthing couldn’t enter certain folders while traversing, and watching failed to be enabled.
- We know that the entire directory tree was traversed because syncthing complains about a folder not explicitly listed in the ignore file.
- The error is one of filesystem watching.
Yet with the same setup, minus filesystem watching, syncthing did not complain. I made sure to restart after toggling so syncthing started from scratch each time.
The docs imply that the entire directory tree will be watched if non top-level patterns are included. This does not appear to be true. Instead, what seens to be happening is IF filesystem watching is enabled, then syncthing will traverse and watch the entire directory tree. If filesystem watching is not enabled, syncthing will still traverse the entire tree. But it will not watch the entire directory tree.
The evidence I submit is as follows, by:
- Using non top-level include patterns;
- having directories in the folder tree with restrictive permissions that would have normally cause syncthing to fail when attempting to watch them;
- disabling watching
syncthing will not output any “Filesystem Watcher Errors”. Hence, no watching was done.
I could be wrong in the following scenario: When watching is disabled, and syncthing still enables watching, but suppresses any errors about it.