Problems with ignore patterns


#1

I’m trying to use advanced ignore patterns on android, and I can’t get it to work.

The idea is to build a whitelist out of an ignore list:

  • First I ignore everything
  • Then I reverse-ignore the stuff I actually want to include, using the “!” prefix.

After some tests, it seems that the ignore file is interpreted from bottom to top, like this:

.thumbnails                5th) ignore thumbs within the included folders. does NOT work
!qux/*/rofl                4th) include all sub-subfolders named 'rofl'. does NOT work
!bar/baz                   3rd) include also bar subfolder. does NOT work
!foo                       2nd) now include just the foo folder. works correctly
**                         1st) ignore everything fo starters. works correctly

(read list bottom to top)

Any idea why 3rd, 4th and 5th patterns do not work?

Thanks in advance!


(Jakob Borg) #2

Patterns are strictly first match wins. However, it’s not as simple as you’d hope to unignore files in subdirectories. There are any number of threads about it here on the forum, but the short of it is that you unignore bar/baz, but the directory bar is only matched by the ** at the end, so Syncthing never descends into it to find bar/baz. You need to explicitly unignore every level down to the file you want.


#3

Alright, knowing that it works with first-match-wins rule, it was easy enough to get the basics to work. Other threads in the forum confirm the syntax to use.

However, I still cannot find a way to whitelist a pattern of subdirectories. Maybe there’s some secret syntax to achieve it.

Let’s take this file structure on disk:

/foo/1/a.txt
/foo/1/b.rnd
/foo/1/BAR/c.txt
/foo/1/BAR/d.rnd

There’s also similarly structured directories with arbitrary names, for example “2”:

/foo/2/a.txt
/foo/2/b.rnd
/foo/2/BAR/c.txt
/foo/2/BAR/d.rnd

And 3, 4, etc.

/foo/3/...
/foo/4/...
/foo/etc/...

I want to synchronize the files inside their BAR subdir, and ignore the rest.

So essentially, I need Syncthing to at least consider the entries inside 1,2,3,4,etc folders, and then keep the BAR entries, and discard the rest that we had just decided to consider in our search for BAR.

Is that doable at all?

Thanks for any help :slight_smile:


(Jakob Borg) #4

I don’t think you can express that policy using the existing ignore language. :confused:


#5

Alright, thanks anyway :slight_smile: