Set ignore pattern on device level

Hey everyone,

I am starting to configure syncthing, so external people have access to our files which are stored on a network share.

Those people belong to certain departments and each department only needs a certain set of files. Note that all department get the same folder shared, as everyone has to start at the “root” folder.

So far I have a .stignore-shared.txt file which I include on my “host” computer (which ist the bridge between the network share and the external people) to ignore a global pattern of files, that no depertment needs.

For each department I want to have a “.stignore-department-A.txt” file which ignores the files that this departments does not need.

And what I would like to do is control the ignore pattern on a device level from my admin interface. So if I add a new device from a certain department, that I can say your ignore pattern is: #include .stignore-department-A.txt

I want to avoid to have to talk to each person and manually copy over a .stiginore file on their computer and rather do it centralized from my admin interface. I haven’t found any settings on the device object to do that.

The only thing I have found is that apparently you can define a “default” ignore pattern which gets copied over when I add a new device as far as I understand:

But the problem is I need different default for each department / device essentially.

Is that somehow possible?

It is not possible for you to control ignore patterns on their device. The relevant #include line needs to be added there. Default ignore patterns are for new folders created by you (on your device).

Hey @calmh

Thanks for the reply and clearing things up.

I found out that before adding a folder or from the perspective of the external person, accepting the folder I share with them, they can type in an ignore pattern and only AFTER accepting the sync actually starts.

That means what I have to do to achieve what I want:

  • Add the device of the external person.
  • Share the folder with them.
  • On external person side type in the ignore pattern of the department manually before accepting the folder.
  • After the sync starts and the ignore-department.txt files are actually synced, replace the manual pattern with the #incude ignore-department.txt line so they stay up to date.

Unfortunately quite a clunky workflow…Would be awesome to be able to do this from the admin interface in the future or have per device ignore patterns.

Maybe you could create as many ignore files as you have departments and have all them stored within the Folder.

The ignore file .deptA-ignore.txt for deptA would look as this:

Other patterns to ignore here

Then have this in the GUI : #include .deptA-ignore.txt of each devices in the department. This will allow you to change the content of each dept*-ignore.txt from your own admin device.

Hope I understood your goal

Hey @cosas,

thanks for your reply!

Maybe you could create as many ignore files as you have departments and have all them stored within the Folder.

Yes that is exactly what I am doing. Currently the root of synced folder looks like this:

some files
some folders

And if I start sharing this folder with a new device from depA, I have to modify the .stignore file on their end to look like this:

#include .stignore-deptA.txt
#include .stignore-shared.txt

The issue is, that I can’t type this pattern in the “Ignore Patterns” tab when I accept the new folder on the department device as the .stignore-deptA.txt and .stignore-shared.txt don’t exist yet because, well the sync didn’t start. And then syncthing will throw an error and refuses to start the sync.

So I essentially have to expand the content of the ignore files first, copy them in the .stignore file of the department, start the sync, and once the .stignore-*.txt files are synced I have replace the content of the department .stignore file with the include statements. Hope that makes sense!

Let me know if you know a smarter workaround.

Hummm, you’re right. The only thing I see for your particular use case (new device in a department) is a per department install script that will download/start ST, then kill it, then tweak config.xml to add in it some devices IDs from deptA and to rename “Default” Folder both name/ID/path and add your #include statement in the folder’s section, rename/create “Sync” dir to e.g. /DeptA so that it matches the folder’s path definition and drop the #include file in it. The remaining job when restarted, I guess you already to it, manually “Accept” this new device in other ones and have them “Accept” it to share the folder they already know.

I’ve no developer skills at all (at least each line of code takes me days :frowning: ) but that seems easy :slight_smile: . The more new devices, the more it’s worth the effort.

1 Like

Thanks for your input!

I haven’t thought about automating it by adjusting the config.xml file on the external device. That is a good idea! And could be done as you said via some sort of installer script.

I could not quite follow your explanation on the part how I would actually programmatically set up my ignore patterns on the external device tough.

I can see how I can with a script add my “host” device and the folder that I want the external device to get in the config.xml file but I did’t quite understand how to transfer my ignore-patterns without actaully starting the syncing progress. (Remember that they are stored in the differnet .st-ignore*.txt files in the root of the sync folder.

I don’t see a “ignore” or “ignore-patterns” element in the folder object, which I could use in the config.xml file:

As far as I understand this is soley defined in the .stignore file which lives in the actual fileystem of the synced folder.

Could you break those steps up again for me in a bit more detail? I did not understand your explanation about the default folder stuff. I don’t want to use the default folder but actually add the folder that I am sharing on my host device. But maybe I got you wrong there.

Sorry I did not get it :slight_smile:

Thanks again

On another note:

I just found that link:

It says here that you can basically “pre-fill” a folder on an external device before sharing it with the local host.

You do it by creating the folder on the external device, adding the folder on the external device in the web ui but copy over the folder ID from the local host. And only after that you start sharing.

I am going to test if that way I can basically already copy over all my .st-ignore*.txt files so when the sync starts they immediatly will be taken in to account.

Yes, copying the appropriate .stignore and .stignore-YOURHOST.txt files to the folder before adding it to the config should work for this.

My bad: even #include file path isn’t stored in the relevant folder’s section of config.xml. Instead it is in the usual .stignore file. So a script should copy the 2 files in the folder.

[Edit]: this allows you to manage remote ignores from within a shared .ignore-deptX if later changes are needed. This will affect all devices in the department that are set this way, from any single device in the cluster.

About the default folder, I don’t use it. Instead I delete it from within ST and I use the ~/Sync dir as the default location for my own shares. There is also an option to instruct ST on 1st run not to create ~/Sync. My advise to use ~/Sync after move/rename is because the relevant section is yet created in config.xml and I know it’s easier to modify than creating from scratch.

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