How to correctly exclude all files and folders except folder ABC and DEF

I would like to share only a few folders from my home directory. Everything within folder ABC and DEF should be shared, but nothing else. Not any other folders and not any files in the home directory.

These patterns works in the sense that only ABC and DEF get synced to the destination:


But Syncthing shows a Filesystem Watcher Error:

Error while traversing /home/marlar/.gvfs: permission denied

It’s true that the permission is denied but why does it scan that folder when it should be ignored?

It also takes very long time to scan even though the two folders are small. This also suggests that SC is scanning it all.

There’s two separate issues here, but they have both the same cause: Negative (!) patterns mean that the entire tree is scanned (not hashed!) to detected explicitly included patterns below an ignored one. Example ignores:


This will detect and add a file parent/foo, even though parent itself would be ignored.

So yes, Syncthing is scanning it all with your patterns

The error comes from the filesystem watcher (to continuously pick up changes) which for the same reason needs to setup watches for the entire tree, but opposed to our own scanning cannot deal with errors on ignored paths by just ignoring them (any error means the entire watch setup fails).

1 Like

If I add a leading slash to the two included folders


they should be bound to the root folder. So SC shouldn’t bother to scan any other folders for included patterns since all inclusions are bound to these two folders.

That would be the correct way to scan, but it still scans it all.

Could you implement this?

Anyway, is there another way to do what I need except adding the folders one by one? (There isn’t just two, it was just an example)

And what if the pattern is !**foo**, how can then syncthing not scan other folders?

Any negative patterns assumes we need to scan everything, regardless of the fact that the pattern is rooted, because there are people with:


I am not a fan of special casing pattern implementation to battle specific edge cases.

You are right of course. But what I mean is that IF (and only if) all the inclusions start with a slash, THEN SC doesn’t need to scan everything because it knows that ALL inclusions will be located within these folders.

That is not really a special case pattern implementation in my opinion. But rather a logical way to interpret the patterns.

The word IF is exactly what makes it a special case.

I am not against the idea as it’s a potential optimization to reduce scan time, but I’d rather people fixed their permissions/folder structure for issues like this. There is nothing preventing you from having two separate folders pointing at the things you want to sync.

Sure, but it was just an example. They could be more and then it would be quite tedious.

The concrete use case is that in Linux many programs store their configurations files in the home directory. I want to synchronize some of these program configs to my laptop. An example is Thunderbird, Remmina and Gimp but there are more:


Instead of adding these folders one by one, it would be so much easier to only include these folders from the Home dir.

I believe it would be fairly easy to implement.

Sure, and I have done that. The only issue is then the very slow scan time which isn’t really necessary here.

I’ll propose something tonight.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.